|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectucar.unidata.util.DateUtil
public class DateUtil
A set of date oriented utilities
Field Summary | |
---|---|
static String[] |
DATE_FORMATS
A set of date formats |
static String[] |
DATE_PATTERNS
a set of regular expressions that go along with the below DATE_FORMATS |
static long |
MILLIS
milliseconds in a millisecond |
static long |
MILLIS_CENTURY
milliseconds in a century (approximately) |
static long |
MILLIS_DAY
milliseconds in a day |
static long |
MILLIS_DECADE
milliseconds in a decade (approximately) |
static long |
MILLIS_HOUR
milliseconds in an hour |
static long |
MILLIS_MILLENIUM
milliseconds in a century (approximately) |
static long |
MILLIS_MINUTE
milliseconds in a minute |
static long |
MILLIS_MONTH
milliseconds in a month (approximately) |
static long |
MILLIS_SECOND
milliseconds in a second |
static long |
MILLIS_WEEK
milliseconds in a week |
static long |
MILLIS_YEAR
milliseconds in a year (approximately) |
static String[] |
MONTH_NAMES
_more_ |
static TimeZone |
TIMEZONE_GMT
timezone |
static TimeZone |
TIMEZONE_UTC
_more_ |
Constructor Summary | |
---|---|
DateUtil()
|
Method Summary | |
---|---|
static long |
daysToMillis(double days)
utility to convert a given number of days to milliseconds |
static Date |
decodeWMODate(String wmoDate,
Date baseDate)
Decode a date from a WMO header of the form ddHHmm. |
static SimpleDateFormat |
findFormatter(String dateString)
This finds the SDF to use for the given date string |
static String |
getCurrentSystemTimeAsISO8601()
format current time |
static Date[] |
getDateRange(String fromDate,
String toDate,
Date dflt)
This gets a date range based on the text dates. |
static SimpleDateFormat[] |
getFormatters()
_more_ |
static Date |
getRelativeDate(Date from,
String relativeTimeString)
Get a new date relative to the given date. |
static String |
getTimeAsISO8601(Date date)
format time |
static String |
getTimeAsISO8601(long time)
format time |
static long |
hoursToMillis(double hour)
utility to convert a given number of hours to milliseconds |
static void |
main(String[] args)
main |
static Date |
max(Date date1,
Date date2)
Get the maximum of the 2 dates |
static double |
millisToHours(double millis)
_more_ |
static double |
millisToMinutes(double millis)
utility to convert a given number of milliseconds to minutes |
static Date |
min(Date date1,
Date date2)
Get the minimum of the 2 dates |
static long |
minutesToMillis(double minutes)
utility to convert a given number of minutes to milliseconds |
static Date |
parse(String s)
Parse the date string |
static Date |
parseRelative(Date baseDate,
String s,
int roundDays)
parse the date string (s) (e.g., -1 hour) that is relative to the given baseDate |
static long |
parseRelativeTimeString(String relativeTimeString)
Return the delta number of milliseconds specified in the relative time string |
static Date |
roundByDay(Date dttm,
int day)
Rounds up or down (if negative) the number of days. |
static double[] |
toSeconds(String[] s)
parse the array of date strings and returns the date as seconds |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String[] MONTH_NAMES
public static final long MILLIS
public static final long MILLIS_SECOND
public static final long MILLIS_MINUTE
public static final long MILLIS_HOUR
public static final long MILLIS_DAY
public static final long MILLIS_WEEK
public static final long MILLIS_MONTH
public static final long MILLIS_YEAR
public static final long MILLIS_DECADE
public static final long MILLIS_CENTURY
public static final long MILLIS_MILLENIUM
public static final TimeZone TIMEZONE_GMT
public static final TimeZone TIMEZONE_UTC
public static final String[] DATE_PATTERNS
public static final String[] DATE_FORMATS
Constructor Detail |
---|
public DateUtil()
Method Detail |
---|
public static String getCurrentSystemTimeAsISO8601()
public static String getTimeAsISO8601(Date date)
date
- date
public static Date min(Date date1, Date date2)
date1
- date1date2
- date2
public static Date max(Date date1, Date date2)
date1
- date1date2
- date2
public static String getTimeAsISO8601(long time)
time
- time
public static Date roundByDay(Date dttm, int day)
dttm
- date to roundday
- number of days
public static SimpleDateFormat[] getFormatters()
public static SimpleDateFormat findFormatter(String dateString)
dateString
- example date
public static Date[] getDateRange(String fromDate, String toDate, Date dflt) throws ParseException
absolute date now (for current time) relative date (e.g., (offset unit), -5 seconds, +2 hours, +5 days, -3 weeks, -1 month This is calculated relative to the other date, e.g: -1 hour, now
fromDate
- from datetoDate
- to datedflt
- base default date
ParseException
- On badnesspublic static Date parseRelative(Date baseDate, String s, int roundDays) throws ParseException
baseDate
- base dates
- date stringroundDays
- round down or up the given number of days
ParseException
- on badnesspublic static Date parse(String s) throws ParseException
s
- date string
ParseException
- on badnesspublic static double[] toSeconds(String[] s) throws ParseException
s
- array of date strings
ParseException
- On badnesspublic static long daysToMillis(double days)
days
- days
public static long hoursToMillis(double hour)
hour
- hours
public static double millisToMinutes(double millis)
millis
- milliseconds
public static double millisToHours(double millis)
millis
- _more_
public static long minutesToMillis(double minutes)
minutes
- minutes
public static Date getRelativeDate(Date from, String relativeTimeString)
from
- base daterelativeTimeString
- Relative time string, e.g., -1 hour
public static long parseRelativeTimeString(String relativeTimeString)
relativeTimeString
- This is of the form "offset unit", e.g.:-1 hour +2 weeks etc.
public static Date decodeWMODate(String wmoDate, Date baseDate)
wmoDate
- WMO header stringbaseDate
- base date to get the year and month
public static void main(String[] args) throws Exception
args
- args
Exception
- On badness
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |