Class ISODate

java.lang.Object
org.jpos.iso.ISODate

public class ISODate extends Object
provides various parsing and format functions used by the ISO 8583 specs.
See Also:
  • Field Details

  • Method Details

    • formatDate

      public static String formatDate(Date d, String pattern)
      Formats a date object, using the default time zone for this host WARNING: See important issue related to date pattern.
      Parameters:
      d - date object to be formatted
      pattern - to be used for formatting
    • formatDate

      public static String formatDate(Date d, String pattern, TimeZone timeZone)
      You should use this version of formatDate() if you want a specific timeZone to calculate the date on. WARNING: See important issue related to date pattern.
      Parameters:
      d - date object to be formatted
      pattern - to be used for formatting
      timeZone - for GMT for example, use TimeZone.getTimeZone("GMT") and for Uruguay use TimeZone.getTimeZone("GMT-03:00")
    • parse

      public static Date parse(String s)
      converts a string in DD/MM/YY format to a Date object Warning: return null on invalid dates (prints Exception to console) Uses default time zone for this host
      Returns:
      parsed Date (or null)
    • parse

      public static Date parse(String s, TimeZone timeZone)
      converts a string in DD/MM/YY format to a Date object Warning: return null on invalid dates (prints Exception to console)
      Parameters:
      s - String in DD/MM/YY recorded in timeZone
      timeZone - for GMT for example, use TimeZone.getTimeZone("GMT") and for Uruguay use TimeZone.getTimeZone("GMT-03:00")
      Returns:
      parsed Date (or null)
    • parseDateTime

      public static Date parseDateTime(String s)
      converts a string in DD/MM/YY HH:MM:SS format to a Date object Warning: return null on invalid dates (prints Exception to console) Uses default time zone for this host
      Returns:
      parsed Date (or null)
    • parseDateTime

      public static Date parseDateTime(String s, TimeZone timeZone)
      converts a string in DD/MM/YY HH:MM:SS format to a Date object Warning: return null on invalid dates (prints Exception to console)
      Parameters:
      s - string in DD/MM/YY HH:MM:SS format recorded in timeZone
      timeZone - for GMT for example, use TimeZone.getTimeZone("GMT") and for Uruguay use TimeZone.getTimeZone("GMT-03:00")
      Returns:
      parsed Date (or null)
    • parseISODate

      public static Date parseISODate(String d)
      try to find out suitable date given [YY[YY]]MMDDhhmmss format
      (difficult thing being finding out appropiate year)
      Parameters:
      d - date formated as [YY[YY]]MMDDhhmmss, typical field 13 + field 12
      Returns:
      Date
    • parseISODate

      public static Date parseISODate(String d, TimeZone timeZone)
      try to find out suitable date given [YY[YY]]MMDDhhmmss format
      (difficult thing being finding out appropiate year)
      Parameters:
      d - date formated as [YY[YY]]MMDDhhmmss, typical field 13 + field 12
      timeZone - for GMT for example, use TimeZone.getTimeZone("GMT") and for Uruguay use TimeZone.getTimeZone("GMT-03:00")
      Returns:
      Date
    • parseISODate

      public static Date parseISODate(String d, long currentTime)
      try to find out suitable date given [YY[YY]]MMDDhhmmss format
      (difficult thing being finding out appropiate year)
      Parameters:
      d - date formated as [YY[YY]]MMDDhhmmss, typical field 13 + field 12
      currentTime - currentTime in millis
      Returns:
      Date
    • parseISODate

      public static Date parseISODate(String d, long currentTime, TimeZone timeZone)
      try to find out suitable date given [YY[YY]]MMDDhhmmss format
      (difficult thing being finding out appropiate year)
      Parameters:
      d - date formated as [YY[YY]]MMDDhhmmss, typical field 13 + field 12
      currentTime - currentTime in millis
      timeZone - for GMT for example, use TimeZone.getTimeZone("GMT") and for Uruguay use TimeZone.getTimeZone("GMT-03:00")
      Returns:
      Date
    • getDateTime

      public static String getDateTime(Date d)
      Returns:
      date in MMddHHmmss format suitable for FIeld 7
    • getDateTime

      public static String getDateTime(Date d, TimeZone timeZone)
      Parameters:
      d - date object to be formatted
      timeZone - for GMT for example, use TimeZone.getTimeZone("GMT") and for Uruguay use TimeZone.getTimeZone("GMT-03:00")
      Returns:
      date in MMddHHmmss format suitable for FIeld 7
    • getTime

      public static String getTime(Date d)
      Returns:
      date in HHmmss format - suitable for field 12
    • getTime

      public static String getTime(Date d, TimeZone timeZone)
      Parameters:
      d - date object to be formatted
      timeZone - for GMT for example, use TimeZone.getTimeZone("GMT") and for Uruguay use TimeZone.getTimeZone("GMT-03:00")
      Returns:
      date in HHmmss format - suitable for field 12
    • getDate

      public static String getDate(Date d)
      Returns:
      date in MMdd format - suitable for field 13
    • getDate

      public static String getDate(Date d, TimeZone timeZone)
      Parameters:
      d - date object to be formatted
      timeZone - for GMT for example, use TimeZone.getTimeZone("GMT") and for Uruguay use TimeZone.getTimeZone("GMT-03:00")
      Returns:
      date in MMdd format - suitable for field 13
    • getANSIDate

      public static String getANSIDate(Date d)
      Returns:
      date in yyMMdd format - suitable for ANSI field 8
    • getANSIDate

      public static String getANSIDate(Date d, TimeZone timeZone)
      Parameters:
      d - date object to be formatted
      timeZone - for GMT for example, use TimeZone.getTimeZone("GMT") and for Uruguay use TimeZone.getTimeZone("GMT-03:00")
      Returns:
      date in yyMMdd format - suitable for ANSI field 8
    • getEuropeanDate

      public static String getEuropeanDate(Date d)
    • getEuropeanDate

      public static String getEuropeanDate(Date d, TimeZone timeZone)
    • getExpirationDate

      public static String getExpirationDate(Date d)
      Returns:
      date in yyMM format - suitable for field 14
    • getExpirationDate

      public static String getExpirationDate(Date d, TimeZone timeZone)
      Parameters:
      d - date object to be formatted
      timeZone - for GMT for example, use TimeZone.getTimeZone("GMT") and for Uruguay use TimeZone.getTimeZone("GMT-03:00")
      Returns:
      date in yyMM format - suitable for field 14
    • getJulianDate

      public static String getJulianDate(Date d)
      Parameters:
      d - date object to be formatted
      Returns:
      date in YDDD format suitable for bit 31 or 37 depending on interchange
    • getJulianDate

      public static String getJulianDate(Date d, TimeZone timeZone)
      Parameters:
      d - date object to be formatted
      timeZone - for GMT for example, use TimeZone.getTimeZone("GMT") and for Uruguay use TimeZone.getTimeZone("GMT-03:00")
      Returns:
      date in YDDD format suitable for bit 31 or 37 depending on interchange
    • formatDuration

      public static String formatDuration(Duration d)