Class DateFormatter

java.lang.Object
noaa.coastwatch.util.DateFormatter

public class DateFormatter extends Object
The DateFormatter class contains a number of static methods to format dates easily based on timezone and Earth location.
Since:
3.1.8
Author:
Peter Hollemans
  • Constructor Details

    • DateFormatter

      public DateFormatter()
  • Method Details

    • formatDate

      public static String formatDate(Date date, String format)
      Creates a string with the specified date formatting. The date is formatted as if it was in the GMT+0 timezone.
      Parameters:
      date - the date to format.
      format - a format string in the style of the Java SimpleDateFormat class.
      Returns:
      a string with the date formatted.
    • formatDate

      public static String formatDate(Date date, String format, TimeZone zone)
      Creates a string with the specified date formatting. The date is formatted as if it was in the specified time zone.
      Parameters:
      date - the date to format.
      format - a format string in the style of the Java SimpleDateFormat class.
      zone - the time zone for formatting.
      Returns:
      a string with the date formatted.
    • formatDate

      public static String formatDate(Date date, String format, EarthLocation loc)
      Creates a string with the specified date formatting. The date is formatted as if it was in the time zone specified by the Earth location longitude.
      Parameters:
      date - the date to format.
      format - a format string in the style of the Java SimpleDateFormat class.
      loc - the earth location used to determine the appropriate time zone.
      Returns:
      a string with the date formatted.
    • parseDate

      public static Date parseDate(String input, String format) throws ParseException
      Creates a date from the specified string and format.
      Parameters:
      input - the input string to parse.
      format - a format string in the style of the Java SimpleDateFormat class.
      Returns:
      a date object or null if the input string cannot be parsed.
      Throws:
      ParseException