Package org.kiwiproject.xml
Class KiwiXmlConverters
java.lang.Object
org.kiwiproject.xml.KiwiXmlConverters
Static utilities for converting to/from XML data types, e.g.
XMLGregorianCalendar.-
Method Summary
Modifier and TypeMethodDescriptionstatic XMLGregorianCalendarConverts aDateto anXMLGregorianCalendarin the default time zone.static XMLGregorianCalendardateToXMLGregorianCalendar(Date date, ZoneId zoneId) Converts aDateto anXMLGregorianCalendarin the given time zone.static XMLGregorianCalendarConverts aDateto anXMLGregorianCalendarin UTC.static XMLGregorianCalendarepochMillisToXMLGregorianCalendar(long epochMillis) Converts milliseconds since the epoch to anXMLGregorianCalendarobject in the default time zone.static XMLGregorianCalendarepochMillisToXMLGregorianCalendar(long epochMillis, ZoneId zoneId) Converts milliseconds since the epoch to anXMLGregorianCalendarobject in the given time zone.static XMLGregorianCalendarepochMillisToXMLGregorianCalendarUTC(long epochMillis) Converts milliseconds since the epoch to anXMLGregorianCalendarobject in UTC.static XMLGregorianCalendarinstantToXMLGregorianCalendar(Instant instant) Converts anInstantobject to anXMLGregorianCalendarin the default time zone.static XMLGregorianCalendarinstantToXMLGregorianCalendar(Instant instant, ZoneId zoneId) Converts anInstantobject to anXMLGregorianCalendarin the given time zone.static XMLGregorianCalendarinstantToXMLGregorianCalendarUTC(Instant instant) Converts anInstantobject to anXMLGregorianCalendarin UTC.static XMLGregorianCalendarCreate a newXMLGregorianCalendarin the default time zone that is initialized to the current date/time.static XMLGregorianCalendarnewXMLGregorianCalendar(ZoneId zoneId) Create a newXMLGregorianCalendarin the given time zone that is initialized to the current date/time.static XMLGregorianCalendarCreate a newXMLGregorianCalendarin UTC that is initialized to the current date/time.static DatexmlGregorianCalendarToDate(XMLGregorianCalendar xmlGregorianCalendar) Given anXMLGregorianCalendar, return its value as aDate.static longxmlGregorianCalendarToEpochMillis(XMLGregorianCalendar xmlGregorianCalendar) Given anXMLGregorianCalendar, return its value in milliseconds since the epoch.static InstantxmlGregorianCalendarToInstant(XMLGregorianCalendar xmlGregorianCalendar) Converts anXMLGregorianCalendarto anInstant.static LocalDateTimexmlGregorianCalendarToLocalDateTime(XMLGregorianCalendar xmlGregorianCalendar) Converts anXMLGregorianCalendarto aLocalDateTimein the default time zone.static LocalDateTimexmlGregorianCalendarToLocalDateTime(XMLGregorianCalendar xmlGregorianCalendar, ZoneId zoneId)
-
Method Details
-
newXMLGregorianCalendar
Create a newXMLGregorianCalendarin the default time zone that is initialized to the current date/time.- Returns:
- a new instance representing the current date/time
-
newXMLGregorianCalendarUTC
Create a newXMLGregorianCalendarin UTC that is initialized to the current date/time.- Returns:
- a new instance representing the current date/time
-
newXMLGregorianCalendar
Create a newXMLGregorianCalendarin the given time zone that is initialized to the current date/time.- Parameters:
zoneId- the time zone for the new GregorianCalendar instance- Returns:
- a new instance representing the current date/time
-
epochMillisToXMLGregorianCalendar
Converts milliseconds since the epoch to anXMLGregorianCalendarobject in the default time zone.- Parameters:
epochMillis- number of milliseconds since the epoch- Returns:
- a new instance representing the given number of epoch milliseconds
-
epochMillisToXMLGregorianCalendarUTC
Converts milliseconds since the epoch to anXMLGregorianCalendarobject in UTC.- Parameters:
epochMillis- number of milliseconds since the epoch- Returns:
- a new instance representing the given number of epoch milliseconds
-
epochMillisToXMLGregorianCalendar
public static XMLGregorianCalendar epochMillisToXMLGregorianCalendar(long epochMillis, ZoneId zoneId) Converts milliseconds since the epoch to anXMLGregorianCalendarobject in the given time zone.- Parameters:
epochMillis- number of milliseconds since the epochzoneId- the time zone for the new GregorianCalendar instance- Returns:
- a new instance representing the given number of epoch milliseconds
-
instantToXMLGregorianCalendar
Converts anInstantobject to anXMLGregorianCalendarin the default time zone.- Parameters:
instant- the instant object to convert- Returns:
- a new instance representing the given instant in time
-
instantToXMLGregorianCalendarUTC
Converts anInstantobject to anXMLGregorianCalendarin UTC.- Parameters:
instant- the instant object to convert- Returns:
- a new instance representing the given instant in time
-
instantToXMLGregorianCalendar
Converts anInstantobject to anXMLGregorianCalendarin the given time zone.- Parameters:
instant- the instant object to convertzoneId- the time zone for the new GregorianCalendar instance- Returns:
- a new instance representing the given instant in time
-
dateToXMLGregorianCalendar
Converts aDateto anXMLGregorianCalendarin the default time zone.- Parameters:
date- the date object to convert- Returns:
- a new instance representing the given date
-
dateToXMLGregorianCalendarUTC
Converts aDateto anXMLGregorianCalendarin UTC.- Parameters:
date- the date object to convert- Returns:
- a new instance representing the given date
-
dateToXMLGregorianCalendar
Converts aDateto anXMLGregorianCalendarin the given time zone.- Parameters:
date- the date object to convertzoneId- the time zone for the new GregorianCalendar instance- Returns:
- a new instance representing the given date
-
xmlGregorianCalendarToInstant
Converts anXMLGregorianCalendarto anInstant.- Parameters:
xmlGregorianCalendar- theXMLGregorianCalendarto convert- Returns:
- the instant representing the given
XMLGregorianCalendar
-
xmlGregorianCalendarToLocalDateTime
public static LocalDateTime xmlGregorianCalendarToLocalDateTime(XMLGregorianCalendar xmlGregorianCalendar) Converts anXMLGregorianCalendarto aLocalDateTimein the default time zone.- Parameters:
xmlGregorianCalendar- theXMLGregorianCalendarto convert- Returns:
- the local date/time representing the given
XMLGregorianCalendar
-
xmlGregorianCalendarToLocalDateTime
public static LocalDateTime xmlGregorianCalendarToLocalDateTime(XMLGregorianCalendar xmlGregorianCalendar, ZoneId zoneId) - Parameters:
xmlGregorianCalendar- theXMLGregorianCalendarto convertzoneId- the time-zone, which may be an offset, not null- Returns:
- the local date/time representing the given
XMLGregorianCalendar
-
xmlGregorianCalendarToEpochMillis
Given anXMLGregorianCalendar, return its value in milliseconds since the epoch.- Parameters:
xmlGregorianCalendar- theXMLGregorianCalendarto convert- Returns:
- the epoch milliseconds representing the given
XMLGregorianCalendar
-
xmlGregorianCalendarToDate
Given anXMLGregorianCalendar, return its value as aDate.- Parameters:
xmlGregorianCalendar- theXMLGregorianCalendarto convert- Returns:
- the date representing the given
XMLGregorianCalendar
-