Package org.kiwiproject.xml
Class KiwiXmlConverters
- java.lang.Object
-
- org.kiwiproject.xml.KiwiXmlConverters
-
public class KiwiXmlConverters extends Object
Static utilities for converting to/from XML data types, e.g.XMLGregorianCalendar.
-
-
Constructor Summary
Constructors Constructor Description KiwiXmlConverters()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static XMLGregorianCalendardateToXMLGregorianCalendar(Date date)Converts aDateto anXMLGregorianCalendarin the default time zone.static XMLGregorianCalendardateToXMLGregorianCalendar(Date date, ZoneId zoneId)Converts aDateto anXMLGregorianCalendarin the given time zone.static XMLGregorianCalendardateToXMLGregorianCalendarUTC(Date date)Converts 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 XMLGregorianCalendarnewXMLGregorianCalendar()Create 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 XMLGregorianCalendarnewXMLGregorianCalendarUTC()Create 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 Detail
-
newXMLGregorianCalendar
public static XMLGregorianCalendar 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
public static XMLGregorianCalendar newXMLGregorianCalendarUTC()
Create a newXMLGregorianCalendarin UTC that is initialized to the current date/time.- Returns:
- a new instance representing the current date/time
-
newXMLGregorianCalendar
public static XMLGregorianCalendar newXMLGregorianCalendar(ZoneId zoneId)
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
public static XMLGregorianCalendar epochMillisToXMLGregorianCalendar(long epochMillis)
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
public static XMLGregorianCalendar epochMillisToXMLGregorianCalendarUTC(long epochMillis)
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
public static XMLGregorianCalendar instantToXMLGregorianCalendar(Instant instant)
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
public static XMLGregorianCalendar instantToXMLGregorianCalendarUTC(Instant instant)
Converts anInstantobject to anXMLGregorianCalendarin UTC.- Parameters:
instant- the instant object to convert- Returns:
- a new instance representing the given instant in time
-
instantToXMLGregorianCalendar
public static XMLGregorianCalendar instantToXMLGregorianCalendar(Instant instant, ZoneId zoneId)
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
public static XMLGregorianCalendar dateToXMLGregorianCalendar(Date date)
Converts aDateto anXMLGregorianCalendarin the default time zone.- Parameters:
date- the date object to convert- Returns:
- a new instance representing the given date
-
dateToXMLGregorianCalendarUTC
public static XMLGregorianCalendar dateToXMLGregorianCalendarUTC(Date date)
Converts aDateto anXMLGregorianCalendarin UTC.- Parameters:
date- the date object to convert- Returns:
- a new instance representing the given date
-
dateToXMLGregorianCalendar
public static XMLGregorianCalendar dateToXMLGregorianCalendar(Date date, ZoneId zoneId)
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
public static Instant xmlGregorianCalendarToInstant(XMLGregorianCalendar xmlGregorianCalendar)
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
public static long xmlGregorianCalendarToEpochMillis(XMLGregorianCalendar xmlGregorianCalendar)
Given anXMLGregorianCalendar, return its value in milliseconds since the epoch.- Parameters:
xmlGregorianCalendar- theXMLGregorianCalendarto convert- Returns:
- the epoch milliseconds representing the given
XMLGregorianCalendar
-
xmlGregorianCalendarToDate
public static Date xmlGregorianCalendarToDate(XMLGregorianCalendar xmlGregorianCalendar)
Given anXMLGregorianCalendar, return its value as aDate.- Parameters:
xmlGregorianCalendar- theXMLGregorianCalendarto convert- Returns:
- the date representing the given
XMLGregorianCalendar
-
-