All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.enonic.xp.util.DateTimeHelper Maven / Gradle / Ivy

The newest version!
package com.enonic.xp.util;

import java.time.Instant;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAccessor;

import static com.google.common.base.Strings.isNullOrEmpty;

public class DateTimeHelper
{
    private static final DateTimeFormatter ISO_DATETIME_FORMATTER = DateTimeFormatter.ISO_DATE_TIME;

    public static Instant parseIsoDateTime( final String value )
    {
        if ( isNullOrEmpty( value ) )
        {
            return null;
        }

        final TemporalAccessor ta = ISO_DATETIME_FORMATTER.parse( value );

        return Instant.from( ta );
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy