Package com.ethlo.time
Class Java8Rfc3339
- java.lang.Object
-
- com.ethlo.time.AbstractRfc3339
-
- com.ethlo.time.Java8Rfc3339
-
- All Implemented Interfaces:
Rfc3339,Rfc3339Formatter,Rfc3339Parser
public class Java8Rfc3339 extends AbstractRfc3339
Java 8 JDK classes. The safe and normally "efficient enough" choice.- Author:
- ethlo - Morten Haraldsen
-
-
Field Summary
-
Fields inherited from class com.ethlo.time.AbstractRfc3339
MAX_FRACTION_DIGITS
-
-
Constructor Summary
Constructors Constructor Description Java8Rfc3339()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Stringformat(Date date, String timezone)Format a date in the given time-zoneStringformat(Date date, String timezone, int fractionDigits)Format the date as a date-time String with specified resolution and time-zone offset, for example 1999-12-31T16:48:36[.123456789]-05:00StringformatUtc(OffsetDateTime date)Format theDateas a UTC formatted date-time stringStringformatUtc(OffsetDateTime date, int fractionDigits)Format the date as a date-time String with specified resolution, aka 1999-12-31T16:48:36[.123456789]ZStringformatUtc(Date date)StringformatUtcMicro(OffsetDateTime date)Format the date as a date-time String with microsecond resolution, aka 1999-12-31T16:48:36.123456ZStringformatUtcMilli(OffsetDateTime date)Format the date as a date-time String with millisecond resolution, for example 1999-12-31T16:48:36.123ZStringformatUtcMilli(Date date)StringformatUtcNano(OffsetDateTime date)Format the date as a date-time String with nanosecond resolution, aka 1999-12-31T16:48:36.123456789ZbooleanisValid(String dateTime)Check whether the string is a valid date-time according to RFC-3339OffsetDateTimeparseDateTime(String s)Parse the date-time and return it as aOffsetDateTime.
-
-
-
Method Detail
-
formatUtc
public String formatUtc(Date date)
Description copied from interface:Rfc3339Formatter- Parameters:
date- The date to format- Returns:
- The formatted string
-
parseDateTime
public OffsetDateTime parseDateTime(String s)
Description copied from interface:Rfc3339ParserParse the date-time and return it as aOffsetDateTime.- Parameters:
s- The date-time string to parse- Returns:
- The
OffsetDateTimeas parsed from the input
-
formatUtc
public String formatUtc(OffsetDateTime date)
Description copied from interface:Rfc3339FormatterFormat theDateas a UTC formatted date-time string- Parameters:
date- The date to format- Returns:
- the formatted string
-
isValid
public boolean isValid(String dateTime)
Description copied from interface:Rfc3339ParserCheck whether the string is a valid date-time according to RFC-3339- Parameters:
dateTime- The date-time to validate- Returns:
- True if valid date-time or null, false otherwise
-
formatUtcMilli
public String formatUtcMilli(OffsetDateTime date)
Description copied from interface:Rfc3339FormatterFormat the date as a date-time String with millisecond resolution, for example 1999-12-31T16:48:36.123Z- Parameters:
date- The date to format- Returns:
- the formatted string
-
formatUtcMicro
public String formatUtcMicro(OffsetDateTime date)
Description copied from interface:Rfc3339FormatterFormat the date as a date-time String with microsecond resolution, aka 1999-12-31T16:48:36.123456Z- Parameters:
date- The date to format- Returns:
- the formatted string
-
formatUtcNano
public String formatUtcNano(OffsetDateTime date)
Description copied from interface:Rfc3339FormatterFormat the date as a date-time String with nanosecond resolution, aka 1999-12-31T16:48:36.123456789Z- Parameters:
date- The date to format- Returns:
- the formatted string
-
formatUtc
public String formatUtc(OffsetDateTime date, int fractionDigits)
Description copied from interface:Rfc3339FormatterFormat the date as a date-time String with specified resolution, aka 1999-12-31T16:48:36[.123456789]Z- Parameters:
date- The date to formatfractionDigits- The number of fractional digits in the second- Returns:
- the formatted string
-
formatUtcMilli
public String formatUtcMilli(Date date)
Description copied from interface:Rfc3339Formatter- Parameters:
date- The date to format- Returns:
- The formatted string
-
format
public String format(Date date, String timezone)
Description copied from interface:Rfc3339FormatterFormat a date in the given time-zone- Parameters:
date- The date to formattimezone- The time-zone- Returns:
- the formatted string
-
format
public String format(Date date, String timezone, int fractionDigits)
Description copied from interface:Rfc3339FormatterFormat the date as a date-time String with specified resolution and time-zone offset, for example 1999-12-31T16:48:36[.123456789]-05:00- Parameters:
date- The date to formattimezone- The time-zonefractionDigits- The number of fraction digits- Returns:
- the formatted string
-
-