Package africa.absa.inception.core.util
Class ISO8601Util
- java.lang.Object
-
- africa.absa.inception.core.util.ISO8601Util
-
public final class ISO8601Util extends Object
The ISO8601Util class provides a helper class for handling ISO 8601 strings of the following format: "2008-03-01T13:00:00+01:00". It also supports parsing the "Z" timezone.- Author:
- Marcus Portmann
-
-
Constructor Summary
Constructors Constructor Description ISO8601Util()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringfromDate(Date date)Transform the Date instance into an ISO 8601 string.static StringfromDateTime(Date date)Transform the Date instance into an ISO 8601 string.static StringfromLocalDate(LocalDate localDate)Transform the LocalDate instance into an ISO 8601 string.static StringfromLocalDateTime(LocalDateTime localDateTime)Transform the LocalDateTime instance into an ISO 8601 string.static StringfromLocalDateTimeAsUTC(LocalDateTime localDateTime)Transform the LocalDateTime instance into an ISO 8601 string.static StringfromLocalTime(LocalTime localTime)Transform the LocalTime instance into an ISO 8601 string.static StringfromZonedDateTime(ZonedDateTime zonedDateTime)Transform the ZonedDateTime instance into an ISO 8601 string.static Stringnow()Get current date and time formatted as ISO 8601 string.static DatetoDate(String iso8601string)Transform ISO 8601 string into a LocalDate instance.static LocalDatetoLocalDate(String iso8601string)Transform ISO 8601 string into a LocalDate instance.static LocalDateTimetoLocalDateTime(String iso8601string)Transform ISO 8601 string into a LocalDateTime instance.static LocalTimetoLocalTime(String iso8601string)Transform ISO 8601 string into a LocalTime instance.static ZonedDateTimetoZonedDateTime(String iso8601string)Transform ISO 8601 string into a ZonedDateTime instance.
-
-
-
Method Detail
-
fromDate
public static String fromDate(Date date)
Transform the Date instance into an ISO 8601 string.- Parameters:
date- the Date instance to transform into an ISO 8601 string- Returns:
- the ISO 8601 string for the Date instance
-
fromDateTime
public static String fromDateTime(Date date)
Transform the Date instance into an ISO 8601 string.- Parameters:
date- the Date instance to transform into an ISO 8601 string- Returns:
- the ISO 8601 string for the Date instance
-
fromLocalDate
public static String fromLocalDate(LocalDate localDate)
Transform the LocalDate instance into an ISO 8601 string.- Parameters:
localDate- the LocalDate instance to transform into an ISO 8601 string- Returns:
- the ISO 8601 string for the LocalDate instance
-
fromLocalDateTimeAsUTC
public static String fromLocalDateTimeAsUTC(LocalDateTime localDateTime)
Transform the LocalDateTime instance into an ISO 8601 string.- Parameters:
localDateTime- the LocalDateTime instance to transform into an ISO 8601 string- Returns:
- the ISO 8601 string for the LocalDateTime instance
-
fromLocalDateTime
public static String fromLocalDateTime(LocalDateTime localDateTime)
Transform the LocalDateTime instance into an ISO 8601 string.- Parameters:
localDateTime- the LocalDateTime instance to transform into an ISO 8601 string- Returns:
- the ISO 8601 string for the LocalDateTime instance
-
fromLocalTime
public static String fromLocalTime(LocalTime localTime)
Transform the LocalTime instance into an ISO 8601 string.- Parameters:
localTime- the LocalTime instance to transform into an ISO 8601 string- Returns:
- the ISO 8601 string for the LocalTime instance
-
fromZonedDateTime
public static String fromZonedDateTime(ZonedDateTime zonedDateTime)
Transform the ZonedDateTime instance into an ISO 8601 string.- Parameters:
zonedDateTime- the ZonedDateTime instance to transform into an ISO 8601 string- Returns:
- the ISO 8601 string for the ZonedDateTime instance
-
now
public static String now()
Get current date and time formatted as ISO 8601 string.- Returns:
- the current date and time formatted as ISO 8601 string
-
toDate
public static Date toDate(String iso8601string)
Transform ISO 8601 string into a LocalDate instance.- Parameters:
iso8601string- the ISO 8601 string to transform- Returns:
- the LocalDate instance for the ISO 8601 string
-
toLocalDate
public static LocalDate toLocalDate(String iso8601string)
Transform ISO 8601 string into a LocalDate instance.- Parameters:
iso8601string- the ISO 8601 string to transform- Returns:
- the LocalDate instance for the ISO 8601 string
-
toLocalDateTime
public static LocalDateTime toLocalDateTime(String iso8601string)
Transform ISO 8601 string into a LocalDateTime instance.- Parameters:
iso8601string- the ISO 8601 string to transform- Returns:
- the LocalDateTime instance for the ISO 8601 string
-
toLocalTime
public static LocalTime toLocalTime(String iso8601string)
Transform ISO 8601 string into a LocalTime instance.- Parameters:
iso8601string- the ISO 8601 string to transform- Returns:
- the LocalTime instance for the ISO 8601 string
-
toZonedDateTime
public static ZonedDateTime toZonedDateTime(String iso8601string)
Transform ISO 8601 string into a ZonedDateTime instance.- Parameters:
iso8601string- the ISO 8601 string to transform- Returns:
- the ZonedDateTime instance for the ISO 8601 string
-
-