Class TMXDateParser

java.lang.Object
org.omegat.util.TMXDateParser

public class TMXDateParser extends Object
Date parser for the 'basic' ISO 8601 format that is advised for TMX dates. There are many variations of the ISO8601 standard (the good thing about standards is that there are so many to choose from :( ) The TMX specification refers to the 'extended' format, but although referring to this standard, it recommends the 'basic' format: YYYYMMDDThhmmssZ. Since all translation tools conform to this format, this parser only parses this variant of the 'basic' format.

DateFormat is not thread-safe, so this class must be instantiated.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Wraps a DateFormat with format YYYYMMDDThhmmssZ able to display a date in UTC time.
  • Method Summary

    Modifier and Type
    Method
    Description
    getTMXDate(long date)
    Returns the string representation of the date according to the preferred TMX date format 'YYYYMMDDThhmmssZ'
    Returns the string representation of the date according to the preferred TMX date format 'YYYYMMDDThhmmssZ'
    parse(String tmxDate)
    Parse the given string as TMX date format (ISO 8601 compatible 'YYYYMMDDThhmmssZ') and returns the Date

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • TMXDateParser

      public TMXDateParser()
      Wraps a DateFormat with format YYYYMMDDThhmmssZ able to display a date in UTC time.
  • Method Details

    • parse

      public Date parse(String tmxDate) throws ParseException
      Parse the given string as TMX date format (ISO 8601 compatible 'YYYYMMDDThhmmssZ') and returns the Date
      Parameters:
      tmxDate - A date representation in YYYYMMDDThhmmssZ format
      Returns:
      a Date instance
      Throws:
      ParseException - if the date is null or not valid
    • getTMXDate

      public String getTMXDate(Date date)
      Returns the string representation of the date according to the preferred TMX date format 'YYYYMMDDThhmmssZ'
      Parameters:
      date - a Date instance
      Returns:
      a string representing the date in the ISO 8601 compatible format 'YYYYMMDDThhmmssZ'
    • getTMXDate

      public String getTMXDate(long date)
      Returns the string representation of the date according to the preferred TMX date format 'YYYYMMDDThhmmssZ'
      Parameters:
      date - unix timestamp (ms since 1970)
      Returns:
      a string representing the date in the ISO 8601 compatible format 'YYYYMMDDThhmmssZ'