Package ucar.visad

Class UtcDate

java.lang.Object
ucar.visad.UtcDate

public final class UtcDate extends Object
A set of utility functions for UTC DateTimes
Author:
Unidata Development Team
  • Field Details

  • Constructor Details

    • UtcDate

      public UtcDate()
      default constructor
  • Method Details

    • getHH

      public static String getHH(DateTime dt)
      Get the hour as a String.
      Parameters:
      dt - DateTime to use
      Returns:
      hour as a String (HH)
    • getHH

      public static String getHH(DateTime dt, TimeZone tz)
      Get the hour as a String.
      Parameters:
      dt - DateTime to use
      tz - the TimeZone to use
      Returns:
      hour as a String (HH)
    • containsTimeMacro

      public static boolean containsTimeMacro(String s)
      See if the string contains a timestamp macro
      Parameters:
      s - the string
      Returns:
      true if it contains the macro
    • containsTimeMacro

      public static boolean containsTimeMacro(String s, String prefix)
      Does this string contain a time macro
      Parameters:
      s - the string
      prefix - the prefix
      Returns:
      true if it contains a time macro
    • applyTimeMacro

      public static String applyTimeMacro(String template, DateTime dttm)
      Apply the timestamp macro to the string
      Parameters:
      template - the timestamp template
      dttm - the DateTime
      Returns:
      a formatted string of form template
    • applyTimeMacro

      public static String applyTimeMacro(String template, DateTime dttm, TimeZone tz)
      Apply the timestamp macro to the string
      Parameters:
      template - the timestamp template
      dttm - the DateTime
      tz - the TimeZone to use
      Returns:
      a formatted string of form template
    • applyTimeMacro

      public static String applyTimeMacro(String template, DateTime dttm, String noTimeLabel)
      Apply the timestamp macro to the string
      Parameters:
      template - the timestamp template
      dttm - the DateTime
      noTimeLabel - the label if dttm is null;
      Returns:
      a formatted string of form template
    • applyTimeMacro

      public static String applyTimeMacro(String template, DateTime dttm, String noTimeLabel, String prefix, String suffix)
      Apply the timestamp macro to the string
      Parameters:
      template - the timestamp template
      dttm - the DateTime
      noTimeLabel - the label if dttm is null;
      prefix - macro prefix
      suffix - macro suffix
      Returns:
      the String with the macro applied
    • applyTimeMacro

      public static String applyTimeMacro(String template, DateTime dttm, String noTimeLabel, String prefix, String suffix, TimeZone tz)
      Apply the timestamp macro to the string
      Parameters:
      template - the timestamp template
      dttm - the DateTime
      noTimeLabel - the label if dttm is null;
      prefix - macro prefix
      suffix - macro suffix
      tz - TimeZone
      Returns:
      the String with the macro applied
    • getHHMM

      public static String getHHMM(DateTime dt)
      Get the hour:minute as a String.
      Parameters:
      dt - DateTime to use
      Returns:
      hour:minute as a String (HH:mm);
    • getHHMM

      public static String getHHMM(DateTime dt, TimeZone tz)
      Get the hour:minute as a String.
      Parameters:
      dt - DateTime to use
      tz - the TimeZone to use
      Returns:
      hour:minute as a String (HH:mm);
    • getYMD

      public static String getYMD(DateTime dt)
      Get the year-month-day as a String
      Parameters:
      dt - DateTime to use
      Returns:
      year-month-day as a String (yyyy-MM-dd);
    • getYMD

      public static String getYMD(DateTime dt, TimeZone tz)
      Get the year-month-day as a String
      Parameters:
      dt - DateTime to use
      tz - the TimeZone to use
      Returns:
      year-month-day as a String (yyyy-MM-dd);
    • getHMS

      public static String getHMS(DateTime dt)
      Get the hour/minute/second as a String
      Parameters:
      dt - DateTime to use
      Returns:
      the hour/minute/second as a String (HH:mm:ss)
    • getHMS

      public static String getHMS(DateTime dt, TimeZone tz)
      Get the hour/minute/second as a String
      Parameters:
      dt - DateTime to use
      tz - the TimeZone to use
      Returns:
      the hour/minute/second as a String (HH:mm:ss)
    • getUtcDate

      public static String getUtcDate(DateTime dt)
      Get the full datetime using the DEFAULT_PATTERN
      Parameters:
      dt - DateTime to use
      Returns:
      the formatted UTC date
    • getIYD

      public static String getIYD(DateTime dt)
      Get the year.jday (IYD_FORMAT) as a String
      Parameters:
      dt - DateTime to use
      Returns:
      year.jday as a String (yyyyDDD);
    • getIYD

      public static String getIYD(DateTime dt, TimeZone tz)
      Get the year.jday (IYD_FORMAT) as a String
      Parameters:
      dt - DateTime to use
      tz - the TimeZone to use
      Returns:
      year.jday as a String (yyyyDDD);
    • formatUtcDate

      public static String formatUtcDate(DateTime dt, String pattern)
      Return a formated date in UTC time. Uses DateTime.formatString() with the UTC (GMT) time zone.
      Parameters:
      dt - DateTime object
      pattern - format pattern
      Returns:
      formatted date.
    • formatUtcDate

      public static String formatUtcDate(DateTime dt, String pattern, TimeZone tz)
      Return a formated date in UTC time. Uses DateTime.formatString() with the UTC (GMT) time zone.
      Parameters:
      dt - DateTime object
      pattern - format pattern
      tz - the TimeZone to use
      Returns:
      formatted date.
    • convertDateTimeToJulianDay

      public static int[] convertDateTimeToJulianDay(DateTime[] dates)
      Convert an array of DateTime objects to an array of the Julian day of each date
      Parameters:
      dates - array of dates
      Returns:
      the corresponding Julian Days
    • convertDateTimeToJulianDay

      public static int[] convertDateTimeToJulianDay(Gridded1DSet timeSet) throws VisADException
      Convert the time set to an array of the Julian days of each date in the set
      Parameters:
      timeSet - set of dates
      Returns:
      the corresponding Julian Days
      Throws:
      VisADException - set must have type of RealType.Time
    • createDateTime

      public static DateTime createDateTime(String dateString) throws VisADException
      Create a DateTime object.
      Parameters:
      dateString - the string specifying the date
      Returns:
      the DateTime object
      Throws:
      VisADException - problem decoding string or creating Data object
    • createDateTime

      public static DateTime createDateTime(String dateString, String pattern) throws VisADException
      Create a DateTime object.
      Parameters:
      dateString - the string specifying the date
      pattern - the format pattern
      Returns:
      the DateTime object
      Throws:
      VisADException - problem decoding string or creating Data object
    • createDateTime

      public static DateTime createDateTime(String dateString, String pattern, TimeZone tz) throws VisADException
      Create a DateTime object.
      Parameters:
      dateString - the string specifying the date
      pattern - the format pattern
      tz - the associated time zone
      Returns:
      the DateTime object
      Throws:
      VisADException - problem decoding string or creating Data object
    • createDateTime

      public static DateTime createDateTime(String dateString, String pattern, TimeZone tz, ucar.nc2.time.Calendar cal) throws VisADException
      Create a DateTime object.
      Parameters:
      dateString - the string specifying the date
      pattern - the format pattern
      tz - the associated time zone
      cal - the associated Calendar
      Returns:
      the DateTime object
      Throws:
      VisADException - problem decoding string or creating Data object