Class DateFormatUtil

java.lang.Object
io.sf.jclf.text.DateFormatUtil

public class DateFormatUtil extends Object
Convenience class for DateFormat utility functions
  • Constructor Details

    • DateFormatUtil

      public DateFormatUtil()
      Generic utility to parse dates.
  • Method Details

    • guessDate

      public Date guessDate(String formatted_date)
      Guesses a date from a String, not knowing the format in advance. Assumes that the date to be guessed is less than SANITY_INTERVAL (20 yrs) from now. Use with caution. TODO: Use locale information, if available, to guess the date.
      Parameters:
      formatted_date - the date to parse.
      Returns:
      the parsed date, or null if could not be parsed.
    • guessDate

      public Date guessDate(Date refdate, String formatted_date)
      Try to guess a date from formatted_date, using refdate as a reference.
      Parameters:
      refdate - the reference date. If the parsed date is not within a sanity interval, it will be rejected and a different parsing format will be used.
      formatted_date - the string to parse.
      Returns:
      the parsed date, or null if could not be parsed.