Package com.ethlo.time
Class ITU
- java.lang.Object
-
- com.ethlo.time.ITU
-
public class ITU extends Object
The main access to the parse and formatting functions in this library.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Stringformat(OffsetDateTime offsetDateTime)Format the input as an RFC-3339 formatted date-time in the timezone of the input.static Stringformat(OffsetDateTime offsetDateTime, int fractionDigits)Format the input as an RFC-3339 formatted date-time in the timezone of the input, with the specified number of fraction digits.static StringformatUtc(OffsetDateTime offsetDateTime)Format the input as an RFC-3339 formatted date-time in the UTC timezone with second resolution.static StringformatUtc(OffsetDateTime offsetDateTime, int fractionDigits)Format the input as an RFC-3339 formatted date-time in the UTC timezonestatic StringformatUtc(OffsetDateTime offsetDateTime, Field lastIncluded)Format the input as an ISO format string, limited to the granularity of the specified field, in the UTC timezone.static StringformatUtcMicro(OffsetDateTime offsetDateTime)Format the input as an RFC-3339 formatted date-time in the UTC timezone with microsecond resolution.static StringformatUtcMilli(OffsetDateTime offsetDateTime)Format the input as an RFC-3339 formatted date-time in the UTC timezone with millisecond resolution.static StringformatUtcNano(OffsetDateTime offsetDateTime)Format the input as an RFC-3339 formatted date-time in the UTC timezone with nanosecond resolutionstatic booleanisValid(String text)Check if the dateTime is valid according to the RFC-3339 specificationstatic booleanisValid(String text, TemporalType... types)Check if the input is valid for one of the specified typesstatic voidparse(String text, TemporalConsumer temporalConsumer)Parse the input, and use callbacks for the type of date/date-time it contains.static <T> Tparse(String text, TemporalHandler<T> temporalHandler)Parse the input, and use callbacks for the type of date/date-time it contains.static OffsetDateTimeparseDateTime(String text)Parse an RFC-3339 formatted date-time to anOffsetDateTimestatic DateTimeparseLenient(String text)Parse an ISO formatted date and optionally time to aDateTime.
-
-
-
Method Detail
-
parseDateTime
public static OffsetDateTime parseDateTime(String text)
Parse an RFC-3339 formatted date-time to anOffsetDateTime- Parameters:
text- The text to parse- Returns:
- The date and time parsed
-
parseLenient
public static DateTime parseLenient(String text)
Parse an ISO formatted date and optionally time to aDateTime. The result has rudimentary checks for correctness, but will not be aware of number of days per specific month or leap-years.- Parameters:
text- The text to parse- Returns:
- The date and time parsed
-
isValid
public static boolean isValid(String text)
Check if the dateTime is valid according to the RFC-3339 specification- Parameters:
text- The input to validate- Returns:
- True if valid, otherwise false
-
formatUtc
public static String formatUtc(OffsetDateTime offsetDateTime, int fractionDigits)
Format the input as an RFC-3339 formatted date-time in the UTC timezone- Parameters:
offsetDateTime- The date-time to formatfractionDigits- The number of fraction digits in the second field- Returns:
- The formatted string
-
formatUtc
public static String formatUtc(OffsetDateTime offsetDateTime, Field lastIncluded)
Format the input as an ISO format string, limited to the granularity of the specified field, in the UTC timezone.- Parameters:
offsetDateTime- The date-time to formatlastIncluded- The last included field- Returns:
- The formatted string
-
format
public static String format(OffsetDateTime offsetDateTime)
Format the input as an RFC-3339 formatted date-time in the timezone of the input.- Parameters:
offsetDateTime- The date-time to format- Returns:
- The formatted string
-
format
public static String format(OffsetDateTime offsetDateTime, int fractionDigits)
Format the input as an RFC-3339 formatted date-time in the timezone of the input, with the specified number of fraction digits.- Parameters:
offsetDateTime- The date-time to formatfractionDigits- The number of fraction digits in the second field- Returns:
- The formatted string
-
formatUtc
public static String formatUtc(OffsetDateTime offsetDateTime)
Format the input as an RFC-3339 formatted date-time in the UTC timezone with second resolution.- Parameters:
offsetDateTime- The date-time to format.- Returns:
- The formatted string with second resolution.
-
formatUtcMilli
public static String formatUtcMilli(OffsetDateTime offsetDateTime)
Format the input as an RFC-3339 formatted date-time in the UTC timezone with millisecond resolution.- Parameters:
offsetDateTime- The date-time to format.- Returns:
- The formatted string with millisecond resolution.
-
formatUtcMicro
public static String formatUtcMicro(OffsetDateTime offsetDateTime)
Format the input as an RFC-3339 formatted date-time in the UTC timezone with microsecond resolution.- Parameters:
offsetDateTime- The date-time to format- Returns:
- The formatted string with microsecond resolution
-
formatUtcNano
public static String formatUtcNano(OffsetDateTime offsetDateTime)
Format the input as an RFC-3339 formatted date-time in the UTC timezone with nanosecond resolution- Parameters:
offsetDateTime- The date-time to format- Returns:
- The formatted string with nanosecond resolution
-
parse
public static void parse(String text, TemporalConsumer temporalConsumer)
Parse the input, and use callbacks for the type of date/date-time it contains. This allows you to handle different granularity inputs with ease!- Parameters:
text- The text to parse as a date/date-timetemporalConsumer- The consumer of the found date/date-time
-
parse
public static <T> T parse(String text, TemporalHandler<T> temporalHandler)
Parse the input, and use callbacks for the type of date/date-time it contains. This allows you to handle different granularity inputs with ease!- Parameters:
text- The text to parse as a date/date-timetemporalHandler- The handler of the found date/date-time
-
isValid
public static boolean isValid(String text, TemporalType... types)
Check if the input is valid for one of the specified types- Parameters:
text- The input to checktypes- The types that are considered valid- Returns:
- True if valid, otherwise false
-
-