Package de.elo.utils

Class ISODate

java.lang.Object
de.elo.utils.ISODate

public class ISODate
extends java.lang.Object
Convesion from java.util.Date to ISO date format. This class is used as a helper class for TimeStamp. Prefer to use TimeStamp in your application instead of ISODate.
  • Field Summary

    Fields 
    Modifier and Type Field Description
    static java.lang.String DATE_FORMAT_NO_SEPARATORS
    Date format without delimiter chars.
    static java.lang.String DATE_FORMAT_SEPARATORS
    Date format with ISO 8601 delimiter chars.
    static int OPT_SEPARATOR
    Formatting option: use ISO 8601 delimiter chars.
  • Constructor Summary

    Constructors 
    Constructor Description
    ISODate()  
  • Method Summary

    Modifier and Type Method Description
    static int getThreadLocaleOptions()
    Get the formatting options of the current thread.
    static java.lang.String now​(java.util.TimeZone tz)
    Return the current date and time in ISO format for the given timezone
    static java.lang.String now​(java.util.TimeZone tz, int opts)
    Return the current date and time in ISO format for the given timezone
    static java.lang.String nowUTC()  
    static java.lang.String parseDate​(java.lang.String sISODate, java.util.TimeZone in, java.util.TimeZone out)
    Converts an ISO date (yyyyMMddHHmmss) from one timezone into an other.
    static java.lang.String parseDate​(java.util.Date date, java.util.TimeZone tz)
    Returns ISO date (yyyyMMddHHmmss) measured in the specified time zone.
    static java.lang.String parseDate​(java.util.Date date, java.util.TimeZone tz, int opts)
    Returns ISO date (yyyyMMddHHmmss) measured in the specified time zone.
    static java.lang.String parseTimestamp​(java.sql.Timestamp ts, java.util.TimeZone tz)  
    static void removeThreadLocalOptions()
    Remove the internally used thread locale object.
    static void setThreadLocaleOptions​(int opts)
    Sets the formatting options of the current thread.
    static java.util.Date toDate​(java.lang.String sISODate, java.util.TimeZone tz)
    Returns a Date object from an ISO date.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

  • Method Details

    • toDate

      public static final java.util.Date toDate​(java.lang.String sISODate, java.util.TimeZone tz)
      Returns a Date object from an ISO date. e. g. 20030214101102 for 14.02.03, 10:11:02
      Parameters:
      sISODate - ISO date (yyyyMMddHHmmss)
      tz - Time zone of sISODate. If null the current default time zone is used.
      Returns:
      Date object
    • parseDate

      public static final java.lang.String parseDate​(java.util.Date date, java.util.TimeZone tz)
      Returns ISO date (yyyyMMddHHmmss) measured in the specified time zone. Formatting options are requested from thread local storage. If the formatting options contain OPT_SEPARATOR, the returned ISO date looks like &qt;yyyy-MM-dd HH:mm:ss&qt;.
      Parameters:
      date - Date object
      tz - Format into this time zone. If null it's formatted into the current default time zone.
      Returns:
      ISO date
      See Also:
      getThreadLocaleOptions()
    • parseDate

      public static final java.lang.String parseDate​(java.lang.String sISODate, java.util.TimeZone in, java.util.TimeZone out)
      Converts an ISO date (yyyyMMddHHmmss) from one timezone into an other.
      Parameters:
      sISODate - ISO date (yyyyMMddHHmmss)
      in - TimeZone of ISO date
      out - TimeZone to convert into
      Returns:
      Date value in ISO format.
    • parseDate

      public static final java.lang.String parseDate​(java.util.Date date, java.util.TimeZone tz, int opts)
      Returns ISO date (yyyyMMddHHmmss) measured in the specified time zone.
      Parameters:
      date - Date object
      tz - Format into this time zone. If null it's formatted into the current default time zone.
      opts - Bitset of OPT_* constants.
      Returns:
      ISO date
    • parseTimestamp

      public static final java.lang.String parseTimestamp​(java.sql.Timestamp ts, java.util.TimeZone tz)
    • now

      public static final java.lang.String now​(java.util.TimeZone tz)
      Return the current date and time in ISO format for the given timezone
      Parameters:
      tz - timezone
      Returns:
      ISO date
    • now

      public static final java.lang.String now​(java.util.TimeZone tz, int opts)
      Return the current date and time in ISO format for the given timezone
      Parameters:
      tz - timezone
      opts - Combination of OPT_* constants.
      Returns:
      ISO date
    • nowUTC

      public static final java.lang.String nowUTC()
    • getThreadLocaleOptions

      public static int getThreadLocaleOptions()
      Get the formatting options of the current thread.
      Returns:
      Options
    • setThreadLocaleOptions

      public static void setThreadLocaleOptions​(int opts)
      Sets the formatting options of the current thread.
      Parameters:
      opts - Options
    • removeThreadLocalOptions

      public static void removeThreadLocalOptions()
      Remove the internally used thread locale object.