Class KiwiXmlConverters

java.lang.Object
org.kiwiproject.xml.KiwiXmlConverters

public final class KiwiXmlConverters extends Object
Static utilities for converting to/from XML data types, e.g. XMLGregorianCalendar.
  • Method Details

    • newXMLGregorianCalendar

      public static XMLGregorianCalendar newXMLGregorianCalendar()
      Create a new XMLGregorianCalendar in 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 new XMLGregorianCalendar in 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 new XMLGregorianCalendar in 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 an XMLGregorianCalendar object 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 an XMLGregorianCalendar object 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 an XMLGregorianCalendar object in the given time zone.
      Parameters:
      epochMillis - number of milliseconds since the epoch
      zoneId - 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 an Instant object to an XMLGregorianCalendar in 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 an Instant object to an XMLGregorianCalendar in 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 an Instant object to an XMLGregorianCalendar in the given time zone.
      Parameters:
      instant - the instant object to convert
      zoneId - 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 a Date to an XMLGregorianCalendar in 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 a Date to an XMLGregorianCalendar in 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 a Date to an XMLGregorianCalendar in the given time zone.
      Parameters:
      date - the date object to convert
      zoneId - the time zone for the new GregorianCalendar instance
      Returns:
      a new instance representing the given date
    • xmlGregorianCalendarToInstant

      public static Instant xmlGregorianCalendarToInstant(XMLGregorianCalendar xmlGregorianCalendar)
      Converts an XMLGregorianCalendar to an Instant.
      Parameters:
      xmlGregorianCalendar - the XMLGregorianCalendar to convert
      Returns:
      the instant representing the given XMLGregorianCalendar
    • xmlGregorianCalendarToLocalDateTime

      public static LocalDateTime xmlGregorianCalendarToLocalDateTime(XMLGregorianCalendar xmlGregorianCalendar)
      Converts an XMLGregorianCalendar to a LocalDateTime in the default time zone.
      Parameters:
      xmlGregorianCalendar - the XMLGregorianCalendar to convert
      Returns:
      the local date/time representing the given XMLGregorianCalendar
    • xmlGregorianCalendarToLocalDateTime

      public static LocalDateTime xmlGregorianCalendarToLocalDateTime(XMLGregorianCalendar xmlGregorianCalendar, ZoneId zoneId)
      Converts an XMLGregorianCalendar to a LocalDateTime using the given ZoneId.
      Parameters:
      xmlGregorianCalendar - the XMLGregorianCalendar to convert
      zoneId - 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 an XMLGregorianCalendar, return its value in milliseconds since the epoch.
      Parameters:
      xmlGregorianCalendar - the XMLGregorianCalendar to convert
      Returns:
      the epoch milliseconds representing the given XMLGregorianCalendar
    • xmlGregorianCalendarToDate

      public static Date xmlGregorianCalendarToDate(XMLGregorianCalendar xmlGregorianCalendar)
      Given an XMLGregorianCalendar, return its value as a Date.
      Parameters:
      xmlGregorianCalendar - the XMLGregorianCalendar to convert
      Returns:
      the date representing the given XMLGregorianCalendar