Class DateTimeUtils

java.lang.Object
at.gv.egovernment.moaspss.util.DateTimeUtils

public class DateTimeUtils extends Object
Utility for parsing and building XML type dateTime, according to ISO 8601.
See Also:
  • http://www.w3.org/2001/XMLSchema-datatypes"
  • Constructor Details

    • DateTimeUtils

      public DateTimeUtils()
  • Method Details

    • buildDateTimeUTC

      public static String buildDateTimeUTC(Calendar cal)
      Builds a dateTime value in UTC from a Calendar value.
      Parameters:
      cal - the Calendar value
      Returns:
      the dateTime value
    • buildDateTimeUTC

      public static String buildDateTimeUTC(Date cal)
      Builds a dateTime value in UTC from a Calendar value.
      Parameters:
      cal - the Calendar value
      Returns:
      the dateTime value
    • buildDate

      public static String buildDate(Calendar cal)
      Builds a dateTime value from a Calendar value.
      Parameters:
      cal - the Calendar value
      Returns:
      the dateTime value
    • buildTime

      public static String buildTime(Calendar cal)
      Builds a dateTime value from a Calendar value.
      Parameters:
      cal - the Calendar value
      Returns:
      the dateTime value
    • parseDateTime

      public static Date parseDateTime(String dateTime) throws ParseException
      Parse a String containing a date and time instant, given in ISO 8601 format.
      Parameters:
      dateTime - The String to parse.
      Returns:
      The Date representation of the contents of dateTime.
      Throws:
      ParseException - Parsing the dateTime failed.
    • calcAge

      public static int calcAge(Calendar dateOfBirth, Calendar now)
      Calculates the age if date of birth is given (for a calendar time stamp)
      Parameters:
      dateOfBirth - Date of Birth
      now - Calendar time stamp at which the age needs to be calculated for
      Returns:
      Age of a person
    • calcAge

      public static int calcAge(Calendar dateOfBirth)
      Calculates the age if date of birth is given as Calendar object
      Parameters:
      dateOfBirth - Date of Birth as Calendar object
      Returns:
      Age of a person
    • calcAge

      public static int calcAge(Date dateOfBirth, Date now)
      Calculates the age if date of birth is given (for a date time stamp)
      Parameters:
      dateOfBirth - Date of Birth
      now - Date time stamp at which the age needs to be calculated for
      Returns:
      Age of a person
    • calcAge

      public static int calcAge(Date dateOfBirth)
      Calculates the age if date of birth is given as Date object
      Parameters:
      dateOfBirth - Date of Birth as Date object
      Returns:
      Age of a person
    • formatPEPSDateToMOADate

      public static String formatPEPSDateToMOADate(String pepsDate)
    • getDateTimeWithFormat

      public static String getDateTimeWithFormat(String format)
      Returns a date as String using a provided format
      Parameters:
      format - Format the date/time should be returned
      Returns:
      Date/Time as String formatted according the provided format