|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eigenbase.util14.DateTimeUtil
public class DateTimeUtil
Utility functions for datetime types: date, time, timestamp. Refactored from SqlParserUtil because they are required by the Jdbc driver. TODO: review methods for performance. Due to allocations required, it may be preferable to introduce a "formatter" with the required state.
Nested Class Summary | |
---|---|
static class |
DateTimeUtil.PrecisionTime
Helper class for parsePrecisionDateTimeLiteral(java.lang.String, java.lang.String, java.util.TimeZone) |
Field Summary | |
---|---|
static String |
DateFormatStr
the SimpleDateFormat string for ISO dates, "yyyy-MM-dd" |
static TimeZone |
defaultZone
the Java default time zone |
static TimeZone |
gmtZone
the GMT time zone |
static long |
MILLIS_PER_DAY
The number of milliseconds in a day. |
static String |
TimeFormatStr
the SimpleDateFormat string for ISO times, "HH:mm:ss" |
static String |
TimestampFormatStr
the SimpleDateFormat string for ISO timestamps, "yyyy-MM-dd HH:mm:ss" |
Constructor Summary | |
---|---|
DateTimeUtil()
|
Method Summary | |
---|---|
static void |
checkDateFormat(String pattern)
Checks if the date/time format is valid |
static TimeZone |
getTimeZone(Calendar cal)
Gets the active time zone based on a Calendar argument |
static SimpleDateFormat |
newDateFormat(String format)
Creates a new date formatter with Farrago specific options. |
static Calendar |
parseDateFormat(String s,
String pattern,
TimeZone tz)
Parses a string using SimpleDateFormat and a given pattern. |
private static Calendar |
parseDateFormat(String s,
String pattern,
TimeZone tz,
ParsePosition pp)
Parses a string using SimpleDateFormat and a given pattern. |
static DateTimeUtil.PrecisionTime |
parsePrecisionDateTimeLiteral(String s,
String pattern,
TimeZone tz)
Parses a string using SimpleDateFormat and a given pattern, and
if present, parses a fractional seconds component. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String DateFormatStr
public static final String TimeFormatStr
public static final String TimestampFormatStr
public static final TimeZone gmtZone
public static final TimeZone defaultZone
public static long MILLIS_PER_DAY
In the fennel calculator, this is the modulo 'mask' when converting TIMESTAMP values to DATE and TIME values.
Constructor Detail |
---|
public DateTimeUtil()
Method Detail |
---|
private static Calendar parseDateFormat(String s, String pattern, TimeZone tz, ParsePosition pp)
SimpleDateFormat
and a given pattern. This
method parses a string at the specified parse position and if successful,
updates the parse position to the index after the last character used.
The parsing is strict and requires months to be less than 12, days to be
less than 31, etc.
s
- string to be parsedpattern
- SimpleDateFormat
patterntz
- time zone in which to interpret string. Defaults to the Java
default time zonepp
- position to start parsing from
public static Calendar parseDateFormat(String s, String pattern, TimeZone tz)
SimpleDateFormat
and a given pattern. The
entire string must match the pattern specified.
s
- string to be parsedpattern
- SimpleDateFormat
patterntz
- time zone in which to interpret string. Defaults to the Java
default time zone
public static DateTimeUtil.PrecisionTime parsePrecisionDateTimeLiteral(String s, String pattern, TimeZone tz)
SimpleDateFormat
and a given pattern, and
if present, parses a fractional seconds component. The fractional seconds
component must begin with a decimal point ('.') followed by numeric
digits. The precision is rounded to a maximum of 3 digits of fractional
seconds precision (to obtain milliseconds).
s
- string to be parsedpattern
- SimpleDateFormat
patterntz
- time zone in which to interpret string. Defaults to the local
time zone
PrecisionTime
initialized
with the parsed value, or null if parsing failed. The PrecisionTime
contains a GMT Calendar and a precision.public static TimeZone getTimeZone(Calendar cal)
public static void checkDateFormat(String pattern)
pattern
- SimpleDateFormat
pattern
IllegalArgumentException
- if the given pattern is invalidpublic static SimpleDateFormat newDateFormat(String format)
format
- SimpleDateFormat
pattern
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |