Package io.inversion.utils
Class ISO8601Utils
java.lang.Object
io.inversion.utils.ISO8601Utils
Utilities methods for manipulating dates in iso8601 format. This is much much faster and GC friendly than using SimpleDateFormat so
highly suitable if you (un)serialize lots of date objects.
Supported parse format: [yyyy-MM-dd|yyyyMMdd][T(hh:mm[:ss[.sss]]|hhmm[ss[.sss]])]?[Z|[+-]hh:mm]]
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringFormat a date into 'yyyy-MM-ddThh:mm:ssZ' (GMT timezone, no milliseconds precision)static StringFormat a date into 'yyyy-MM-ddThh:mm:ss[.sss]Z' (GMT timezone)static StringFormat date into yyyy-MM-ddThh:mm:ss[.sss][Z|[+-]hh:mm]static Dateparse(String date, ParsePosition pos) Parse a date from ISO-8601 formatted string.static TimeZoneDeprecated.since 2.6
-
Constructor Details
-
ISO8601Utils
public ISO8601Utils()
-
-
Method Details
-
timeZoneGMT
Deprecated.since 2.6Accessor for static GMT timezone instance. -
format
Format a date into 'yyyy-MM-ddThh:mm:ssZ' (GMT timezone, no milliseconds precision)- Parameters:
date- the date to format- Returns:
- the date formatted as 'yyyy-MM-ddThh:mm:ssZ'
-
format
Format a date into 'yyyy-MM-ddThh:mm:ss[.sss]Z' (GMT timezone)- Parameters:
date- the date to formatmillis- true to include millis precision otherwise false- Returns:
- the date formatted as 'yyyy-MM-ddThh:mm:ss[.sss]Z'
-
format
Format date into yyyy-MM-ddThh:mm:ss[.sss][Z|[+-]hh:mm]- Parameters:
date- the date to formatmillis- true to include millis precision otherwise falsetz- timezone to use for the formatting (GMT will produce 'Z')- Returns:
- the date formatted as yyyy-MM-ddThh:mm:ss[.sss][Z|[+-]hh:mm]
-
parse
Parse a date from ISO-8601 formatted string. It expects a format [yyyy-MM-dd|yyyyMMdd][T(hh:mm[:ss[.sss]]|hhmm[ss[.sss]])]?[Z|[+-]hh:mm]]- Parameters:
date- ISO string to parse in the appropriate format.pos- The position to start parsing from, updated to where parsing stopped.- Returns:
- the parsed date
- Throws:
ParseException- if the date is not in the appropriate format
-