|
||||||||||
| 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 java.lang.String[] |
DATE_FORMATS
A set of date formats |
static java.lang.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 java.lang.String[] |
MONTH_NAMES
_more_ |
static java.util.TimeZone |
TIMEZONE_GMT
timezone |
static java.util.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 java.util.Date |
decodeWMODate(java.lang.String wmoDate,
java.util.Date baseDate)
Decode a date from a WMO header of the form ddHHmm. |
static java.text.SimpleDateFormat |
findFormatter(java.lang.String dateString)
This finds the SDF to use for the given date string |
static java.lang.String |
getCurrentSystemTimeAsISO8601()
format current time |
static java.util.Date[] |
getDateRange(java.lang.String fromDate,
java.lang.String toDate,
java.util.Date dflt)
This gets a date range based on the text dates. |
static java.text.SimpleDateFormat[] |
getFormatters()
_more_ |
static java.util.Date |
getRelativeDate(java.util.Date from,
java.lang.String relativeTimeString)
Get a new date relative to the given date. |
static java.lang.String |
getTimeAsISO8601(java.util.Date date)
format time |
static java.lang.String |
getTimeAsISO8601(long time)
format time |
static long |
hoursToMillis(double hour)
utility to convert a given number of hours to milliseconds |
static void |
main(java.lang.String[] args)
main |
static java.util.Date |
max(java.util.Date date1,
java.util.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 java.util.Date |
min(java.util.Date date1,
java.util.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 java.util.Date |
parse(java.lang.String s)
Parse the date string |
static java.util.Date |
parseRelative(java.util.Date baseDate,
java.lang.String s,
int roundDays)
parse the date string (s) (e.g., -1 hour) that is relative to the given baseDate |
static long |
parseRelativeTimeString(java.lang.String relativeTimeString)
Return the delta number of milliseconds specified in the relative time string |
static java.util.Date |
roundByDay(java.util.Date dttm,
int day)
Rounds up or down (if negative) the number of days. |
static double[] |
toSeconds(java.lang.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 java.lang.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 java.util.TimeZone TIMEZONE_GMT
public static final java.util.TimeZone TIMEZONE_UTC
public static final java.lang.String[] DATE_PATTERNS
public static final java.lang.String[] DATE_FORMATS
| Constructor Detail |
|---|
public DateUtil()
| Method Detail |
|---|
public static java.lang.String getCurrentSystemTimeAsISO8601()
public static java.lang.String getTimeAsISO8601(java.util.Date date)
date - date
public static java.util.Date min(java.util.Date date1,
java.util.Date date2)
date1 - date1date2 - date2
public static java.util.Date max(java.util.Date date1,
java.util.Date date2)
date1 - date1date2 - date2
public static java.lang.String getTimeAsISO8601(long time)
time - time
public static java.util.Date roundByDay(java.util.Date dttm,
int day)
dttm - date to roundday - number of days
public static java.text.SimpleDateFormat[] getFormatters()
public static java.text.SimpleDateFormat findFormatter(java.lang.String dateString)
dateString - example date
public static java.util.Date[] getDateRange(java.lang.String fromDate,
java.lang.String toDate,
java.util.Date dflt)
throws java.text.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
java.text.ParseException - On badness
public static java.util.Date parseRelative(java.util.Date baseDate,
java.lang.String s,
int roundDays)
throws java.text.ParseException
baseDate - base dates - date stringroundDays - round down or up the given number of days
java.text.ParseException - on badness
public static java.util.Date parse(java.lang.String s)
throws java.text.ParseException
s - date string
java.text.ParseException - on badness
public static double[] toSeconds(java.lang.String[] s)
throws java.text.ParseException
s - array of date strings
java.text.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 java.util.Date getRelativeDate(java.util.Date from,
java.lang.String relativeTimeString)
from - base daterelativeTimeString - Relative time string, e.g., -1 hour
public static long parseRelativeTimeString(java.lang.String relativeTimeString)
relativeTimeString - This is of the form "offset unit", e.g.:-1 hour +2 weeks etc.
public static java.util.Date decodeWMODate(java.lang.String wmoDate,
java.util.Date baseDate)
wmoDate - WMO header stringbaseDate - base date to get the year and month
public static void main(java.lang.String[] args)
throws java.lang.Exception
args - args
java.lang.Exception - On badness
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||