Class UnlocalizedDateTimeFormat


  • public final class UnlocalizedDateTimeFormat
    extends java.lang.Object

    UnlocalizedDateTimeFormat is a utility class to convert Date objects to an unlocalized, time-zone independent, character-set-independent string format and vice versa.

    This format is intended for file import/export and data transfer between systems as an independent data format.

    This format is explicitly not to use for GUI-clients as they usually should attend localization, time-zone and so on.

    The format is more or less like a SimpleDateFormat format of "Gyyyy-MM-dd HH:mm:ss.SSS" with an era of "-" for BC and none era for AD.

    This format is optimized this single format and for speed, so it is much faster than the SimpleDateFormat.

    An instance of this UnlocalizedDateTimeFormat can be used in several threads concurrently.

    Author:
    agz
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String format​(java.util.Date date)
      Formats the specified Date to an unlocalized string.
      static java.util.Date parse​(java.lang.String unlocalizedString)
      Parses the specified unlocalized string to a Date.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • format

        public static java.lang.String format​(java.util.Date date)
        Formats the specified Date to an unlocalized string.

        The specified Date must not be null.

        Parameters:
        date - Date to format
        Returns:
        unlocalized string
        See Also:
        parse(String)
      • parse

        public static java.util.Date parse​(java.lang.String unlocalizedString)
                                    throws java.text.ParseException
        Parses the specified unlocalized string to a Date.

        The specified unlocalized string must not be null.

        Parameters:
        unlocalizedString - unlocalized string to parse
        Returns:
        Date
        Throws:
        java.text.ParseException - if the specified string is invalid
        See Also:
        format(Date)