Package ucar.visad
Class UtcDate
java.lang.Object
ucar.visad.UtcDate
A set of utility functions for UTC DateTimes
- Author:
- Unidata Development Team
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Default time formatstatic final TimeZone
GMT Timezonestatic final String
hour format string (HH)static final String
hour:minute format string (HH:mm)static final String
hour:minute:second format string (HH:mm:ss)static final String
Year-Day format stringstatic final String
Julian day format stringstatic final String
timestamp macro identifierstatic final String
timestamp macro identifierstatic final String
Year-Month-Day format string -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
applyTimeMacro
(String template, DateTime dttm) Apply the timestamp macro to the stringstatic String
applyTimeMacro
(String template, DateTime dttm, String noTimeLabel) Apply the timestamp macro to the stringstatic String
Apply the timestamp macro to the stringstatic String
applyTimeMacro
(String template, DateTime dttm, String noTimeLabel, String prefix, String suffix, TimeZone tz) Apply the timestamp macro to the stringstatic String
applyTimeMacro
(String template, DateTime dttm, TimeZone tz) Apply the timestamp macro to the stringstatic boolean
See if the string contains a timestamp macrostatic boolean
containsTimeMacro
(String s, String prefix) Does this string contain a time macrostatic int[]
convertDateTimeToJulianDay
(DateTime[] dates) Convert an array of DateTime objects to an array of the Julian day of each datestatic int[]
convertDateTimeToJulianDay
(Gridded1DSet timeSet) Convert the time set to an array of the Julian days of each date in the setstatic DateTime
createDateTime
(String dateString) Create a DateTime object.static DateTime
createDateTime
(String dateString, String pattern) Create a DateTime object.static DateTime
createDateTime
(String dateString, String pattern, TimeZone tz) Create a DateTime object.static DateTime
createDateTime
(String dateString, String pattern, TimeZone tz, ucar.nc2.time.Calendar cal) Create a DateTime object.static String
formatUtcDate
(DateTime dt, String pattern) Return a formated date in UTC time.static String
formatUtcDate
(DateTime dt, String pattern, TimeZone tz) Return a formated date in UTC time.static String
Get the hour as a String.static String
Get the hour as a String.static String
Get the hour:minute as a String.static String
Get the hour:minute as a String.static String
Get the hour/minute/second as a Stringstatic String
Get the hour/minute/second as a Stringstatic String
Get the year.jday (IYD_FORMAT) as a Stringstatic String
Get the year.jday (IYD_FORMAT) as a Stringstatic String
getUtcDate
(DateTime dt) Get the full datetime using the DEFAULT_PATTERNstatic String
Get the year-month-day as a Stringstatic String
Get the year-month-day as a String
-
Field Details
-
MACRO_TIMESTAMP
timestamp macro identifier- See Also:
-
TEMPLATE_TIMEFORMAT
timestamp macro identifier- See Also:
-
YMD_FORMAT
Year-Month-Day format string- See Also:
-
HMS_FORMAT
hour:minute:second format string (HH:mm:ss)- See Also:
-
HH_MM_FORMAT
hour:minute format string (HH:mm)- See Also:
-
HH_FORMAT
hour format string (HH)- See Also:
-
IYD_FORMAT
Year-Day format string- See Also:
-
JDAY_FORMAT
Julian day format string- See Also:
-
GMT
GMT Timezone -
DEFAULT_PATTERN
Default time format- See Also:
-
-
Constructor Details
-
UtcDate
public UtcDate()default constructor
-
-
Method Details
-
getHH
Get the hour as a String.- Parameters:
dt
- DateTime to use- Returns:
- hour as a String (HH)
-
getHH
Get the hour as a String.- Parameters:
dt
- DateTime to usetz
- the TimeZone to use- Returns:
- hour as a String (HH)
-
containsTimeMacro
See if the string contains a timestamp macro- Parameters:
s
- the string- Returns:
- true if it contains the macro
-
containsTimeMacro
Does this string contain a time macro- Parameters:
s
- the stringprefix
- the prefix- Returns:
- true if it contains a time macro
-
applyTimeMacro
Apply the timestamp macro to the string- Parameters:
template
- the timestamp templatedttm
- the DateTime- Returns:
- a formatted string of form template
-
applyTimeMacro
Apply the timestamp macro to the string- Parameters:
template
- the timestamp templatedttm
- the DateTimetz
- the TimeZone to use- Returns:
- a formatted string of form template
-
applyTimeMacro
Apply the timestamp macro to the string- Parameters:
template
- the timestamp templatedttm
- the DateTimenoTimeLabel
- 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 templatedttm
- the DateTimenoTimeLabel
- the label if dttm is null;prefix
- macro prefixsuffix
- 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 templatedttm
- the DateTimenoTimeLabel
- the label if dttm is null;prefix
- macro prefixsuffix
- macro suffixtz
- TimeZone- Returns:
- the String with the macro applied
-
getHHMM
Get the hour:minute as a String.- Parameters:
dt
- DateTime to use- Returns:
- hour:minute as a String (HH:mm);
-
getHHMM
Get the hour:minute as a String.- Parameters:
dt
- DateTime to usetz
- the TimeZone to use- Returns:
- hour:minute as a String (HH:mm);
-
getYMD
Get the year-month-day as a String- Parameters:
dt
- DateTime to use- Returns:
- year-month-day as a String (yyyy-MM-dd);
-
getYMD
Get the year-month-day as a String- Parameters:
dt
- DateTime to usetz
- the TimeZone to use- Returns:
- year-month-day as a String (yyyy-MM-dd);
-
getHMS
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
Get the hour/minute/second as a String- Parameters:
dt
- DateTime to usetz
- the TimeZone to use- Returns:
- the hour/minute/second as a String (HH:mm:ss)
-
getUtcDate
Get the full datetime using the DEFAULT_PATTERN- Parameters:
dt
- DateTime to use- Returns:
- the formatted UTC date
-
getIYD
Get the year.jday (IYD_FORMAT) as a String- Parameters:
dt
- DateTime to use- Returns:
- year.jday as a String (yyyyDDD);
-
getIYD
Get the year.jday (IYD_FORMAT) as a String- Parameters:
dt
- DateTime to usetz
- the TimeZone to use- Returns:
- year.jday as a String (yyyyDDD);
-
formatUtcDate
Return a formated date in UTC time. Uses DateTime.formatString() with the UTC (GMT) time zone.- Parameters:
dt
- DateTime objectpattern
- format pattern- Returns:
- formatted date.
-
formatUtcDate
Return a formated date in UTC time. Uses DateTime.formatString() with the UTC (GMT) time zone.- Parameters:
dt
- DateTime objectpattern
- format patterntz
- the TimeZone to use- Returns:
- formatted date.
-
convertDateTimeToJulianDay
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
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
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
Create a DateTime object.- Parameters:
dateString
- the string specifying the datepattern
- 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 datepattern
- the format patterntz
- 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 datepattern
- the format patterntz
- the associated time zonecal
- the associated Calendar- Returns:
- the DateTime object
- Throws:
VisADException
- problem decoding string or creating Data object
-