|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectjava.text.Format
com.davisor.data.Type
com.davisor.data.LocaleType
com.davisor.data.FormatType
com.davisor.data.DateFormatType
DateFormatType implements a base class for time related types. Date formats are specified by date locale, pattern, style, and time zone. An unspecified locale suggests SQL date formatting rules.
Date format locale is inherited from the LocaleType
super-class. The format pattern is handled by the Java
java.text.SimpleDateFormat class. The format style
equals one of the Java java.text.DateFormat style
codes:
The default time zone is assumed to be GMT (instead of e.g. system default). This makes time arithmetics more robust. It works well also in the typical cases where the data time zone and chart axis time zone are the same.
format := locale
style|pattern ";" locale
timeZone ";" style|pattern ";" locale
locale := language [ "_" country [ "_" variant ]]
style := "default" | "full" | "long" | "medium" | "short"
pattern := [prefix] { dateComponent } [suffix]
timeZone := [ "+"|"-" ] offset
A dateComponent is a time
and date field pattern letter as understood by the
java.text.SimpleDateFormat class:
| Letter | Date or Time Component | Presentation | Examples |
|---|---|---|---|
G |
Era designator | Text | AD |
y |
Year | Year | 1996; 96 |
M |
Month in year | Month | July; Jul; 07 |
w |
Week in year | Number | 27 |
W |
Week in month | Number | 2 |
D |
Day in year | Number | 189 |
d |
Day in month | Number | 10 |
F |
Day of week in month | Number | 2 |
E |
Day in week | Text | Tuesday; Tue |
a |
Am/pm marker | Text | PM |
H |
Hour in day (0-23) | Number | 0 |
k |
Hour in day (1-24) | Number | 24 |
K |
Hour in am/pm (0-11) | Number | 0 |
h |
Hour in am/pm (1-12) | Number | 12 |
m |
Minute in hour | Number | 30 |
s |
Second in minute | Number | 55 |
S |
Millisecond | Number | 978 |
z |
Time zone | General time zone |
Pacific Standard Time;
PST;
GMT-08:00 |
Z |
Time zone | RFC 822 time zone | -0800 |
java.text.SimpleDateFormat
documentation for more complete documentation.
createCalendar(Date,TimeZone,Locale),
DateType,
TimestampType,
Serialized Form| Nested Class Summary |
| Nested classes inherited from class java.text.Format |
java.text.Format.Field |
| Field Summary | |
static java.util.TimeZone |
GMT
Greenwich Mean Time zone (GMT +0:00). |
static java.util.TimeZone |
LOCAL
System default time zone, typically representing the local time zone. |
protected int |
M_style
Date format style. |
protected java.util.TimeZone |
M_timeZone
Date time zone. |
| Fields inherited from class com.davisor.data.FormatType |
M_pattern, M_sample |
| Fields inherited from class com.davisor.data.LocaleType |
DEFAULT_LOCALE, M_locale |
| Fields inherited from class com.davisor.data.Type |
METADATA_GROUP, METADATA_NAME, METADATA_PARENT, METADATA_SUBCHANNELS, TYPENAME |
| Constructor Summary | |
protected |
DateFormatType(DateFormatType dft)
Deep copy constructor. |
protected |
DateFormatType(java.lang.String typeName,
java.lang.String dataName,
java.lang.String id,
java.util.Map metaData,
java.util.Locale locale,
java.lang.String pattern,
java.lang.Object sample,
int style,
java.util.TimeZone timeZone)
Creates a new date format type. |
| Method Summary | |
java.util.Calendar |
createCalendar()
Creates a new calendar for the current locale and timezone, not set to any particular date. |
static java.util.Calendar |
createCalendar(CalendarField field)
Creates a new calendar for the current locale and GMT time zone, set to zero date (January 1, 1970, 00:00:00 GMT) plus given field value. |
static java.util.Calendar |
createCalendar(CalendarField field1,
CalendarField field2)
Creates a new calendar for the current locale and GMT time zone, set to zero date (January 1, 1970, 00:00:00 GMT) plus given field values. |
java.util.Calendar |
createCalendar(java.util.Date date)
Creates a new calendar for the current locale and time zone, set to given date. |
java.util.Calendar |
createCalendar(java.util.Date date,
java.util.TimeZone timeZone)
Creates a new calendar for the current locale and given time zone, set to a given date. |
static java.util.Calendar |
createCalendar(java.util.Date date,
java.util.TimeZone timeZone,
java.util.Locale locale)
Creates a new calendar for the given locale and time zone, set to a given date. |
protected java.text.Format |
createFormatter()
Creates a new format instance suitable for the purposes of this class. |
java.util.Date |
dateValue(java.lang.String stringValue,
java.text.ParsePosition status)
Parses a timestamp string as a timestamp. |
boolean |
equals(java.lang.Object o)
Tests if this object is equal with another object. |
java.lang.String |
getFormat()
Gets the date format specification string. |
CalendarFieldData |
getLast(DataValue dataValue)
Gets the most significant calendar field value from given time-oriented data value. |
int |
getStyle()
Gets the current date format style. |
java.util.TimeZone |
getTimeZone()
Gets the current date format time zone. |
java.lang.Class |
getValueClass()
Gets value container class. |
int |
hashCode()
Returns a hash code value for the object. |
void |
setFormat(java.lang.String format)
Sets the localization specification string. |
void |
setStyle(int style)
Sets the current date format style. |
void |
setTimeZone(java.util.TimeZone timeZone)
Sets the current date format time zone. |
java.lang.String |
stringValue(java.util.Date value)
Formats a timestamp as a timestamp string. |
void |
strip(java.util.Calendar calendar)
Clears selected calendar fields to make the calendar value consistent with current type. |
DataValue |
toData(java.util.Date date)
Converts a date to a date value of a type best suited to represent it. |
DataValue |
toData(long milliseconds)
Converts a milliseconds value to a date value of a type best suited to represent it. |
DataValue |
toData(java.lang.Object objectValue)
Converts an object to a data value. |
DataValue |
toData(java.lang.String stringValue,
java.text.ParsePosition status)
Converts a string to a data value. |
| Methods inherited from class com.davisor.data.FormatType |
clearFormatter, getFormatter, getPattern, getSample, setFormat, setLocale, setPattern, setSample |
| Methods inherited from class com.davisor.data.LocaleType |
getLocale, setLocale |
| Methods inherited from class com.davisor.data.Type |
ceil, check, check, compare, create, create, create, create, create, dup, dup, floor, format, getCompatibility, getDataName, getId, getID, getMetaData, getMetaData, getSpecs, getSQLCode, getSQLName, getSQLName, getTypeName, isNull, parseObject, register, register, setDataName, setId, setID, setMetaData, setMetaData, setSpecs, toData, toData, toString, toXML, xmlEnd, xmlStart, zero |
| Methods inherited from class java.text.Format |
clone, format, formatToCharacterIterator, parseObject |
| Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final java.util.TimeZone GMT
public static final java.util.TimeZone LOCAL
protected int M_style
protected java.util.TimeZone M_timeZone
| Constructor Detail |
protected DateFormatType(DateFormatType dft)
protected DateFormatType(java.lang.String typeName,
java.lang.String dataName,
java.lang.String id,
java.util.Map metaData,
java.util.Locale locale,
java.lang.String pattern,
java.lang.Object sample,
int style,
java.util.TimeZone timeZone)
typeName - type namedataName - data name (may be null)id - type identity (may be null)metaData - type meta data map (may be null)locale - type locale (may be null)pattern - format pattern (may be null)sample - format sample (may be null)style - date format style as defined by DateFormat classtimeZone - date format time zone| Method Detail |
protected java.text.Format createFormatter()
This particular implementation returns a date-time instance.
Current pattern is applied to it only if it is also a
SimpleDateFormat instance. The format time zone is
set as returned by getTimeZone().
createFormatter in class FormatTypeDateType.createFormatter(),
TimeType.createFormatter()public boolean equals(java.lang.Object o)
Date format types are equal if their super-classes and styles are.
equals in interface java.util.Comparatorequals in class FormatTypeFormatType.equals(java.lang.Object)public int hashCode()
hashCode in class FormatTypeCompare.hashCode(java.lang.Object)public java.util.Calendar createCalendar()
createCalendar(Date),
createCalendar(Date,TimeZone),
createCalendar(Date,TimeZone,Locale),
createCalendar(CalendarField),
createCalendar(CalendarField,CalendarField)public java.util.Calendar createCalendar(java.util.Date date)
createCalendar(),
createCalendar(Date,TimeZone),
createCalendar(Date,TimeZone,Locale),
createCalendar(CalendarField),
createCalendar(CalendarField,CalendarField)
public java.util.Calendar createCalendar(java.util.Date date,
java.util.TimeZone timeZone)
date - calendar initial date (may be null)timeZone - calendar time zone (may be null)createCalendar(),
createCalendar(Date),
createCalendar(Date,TimeZone,Locale),
createCalendar(CalendarField),
createCalendar(CalendarField,CalendarField),
LocaleType.getLocale()
public static java.util.Calendar createCalendar(java.util.Date date,
java.util.TimeZone timeZone,
java.util.Locale locale)
null, the
system default locale is used. If the given time zone is
null, the default GMT time zone is used. If the
given date is null, a null
calendar is returned.
date - calendar initial date (may be null)timeZone - calendar time zone (may be null)locale - calendar locale (may be null)createCalendar(),
createCalendar(Date),
createCalendar(Date,TimeZone),
createCalendar(CalendarField),
createCalendar(CalendarField,CalendarField)public static java.util.Calendar createCalendar(CalendarField field)
field - calendar field codecreateCalendar(),
createCalendar(Date),
createCalendar(Date,TimeZone),
createCalendar(Date,TimeZone,Locale),
createCalendar(CalendarField,CalendarField)
public static java.util.Calendar createCalendar(CalendarField field1,
CalendarField field2)
field1 - first calendar fieldfield2 - second calendar fieldcreateCalendar(),
createCalendar(Date),
createCalendar(Date,TimeZone),
createCalendar(Date,TimeZone,Locale),
createCalendar(CalendarField)
public java.util.Date dateValue(java.lang.String stringValue,
java.text.ParsePosition status)
throws InvalidDataException
stringValue - timestamp stringstatus - parse status (may be null)
InvalidDataException - 'value' is invalid as a timestamp stringFormatType.getFormatter()
public CalendarFieldData getLast(DataValue dataValue)
throws InvalidDataException
CalendarData
CalendarFieldData
TimestampData
java.util.Date
dataValue - value to get the most significant time field value from
InvaliDataException - if given data value type is not supported
InvalidDataExceptionpublic int getStyle()
setStyle(int)public java.util.TimeZone getTimeZone()
setTimeZone(java.util.TimeZone)public void setStyle(int style)
getStyle()public void setTimeZone(java.util.TimeZone timeZone)
null time
zone indicates the default GMT time zone.
getTimeZone()public java.lang.String stringValue(java.util.Date value)
value - timestamp value (may be null)
null
or the time of value is TimestampData.NaT, the return
value is an empty string.FormatType.getFormatter(),
setFormat(java.lang.String)public void strip(java.util.Calendar calendar)
This default implementation does not clear any fields.
calendar - calendar to be stripped (will be modified)public DataValue toData(long milliseconds)
milliseconds - milliseconds valuetoData(Date)public DataValue toData(java.util.Date date)
If the date represents a date only, a DateData data
object is returned. If the date represents time only, a TimeData data object is returned. Otherwise, a TimestampData object is returned.
If the date is null, or the value of the date is
TimestampData.NaT, a new TimestampData object with a
TimestampData.NaT value is returned.
date - date value (may be null)strip(java.util.Calendar),
CalendarFields.isDate(),
CalendarFields.isTime(),
CalendarFields.isTimestamp()public java.lang.String getFormat()
; characters.
getFormat in class FormatTypesetFormat(java.lang.String)public void setFormat(java.lang.String format)
; characters. Any component
may also be missing.
The time zone, if present, is expressed as a integer value that tells the time difference in hours to Greenwhich Mean Time. If time zone is not set, the default GMT time zone is assumed.
A style keyword, if present, must be one of the following:
Java date format pattern, if present, must conform to the pattern
rules set by standard SimpleDateFormat, except that
the pattern must not contain the ; characters.
Style keyword and date pattern are mutually exclusive settings, and they must not appear together. If both are missing, SQL date format will be used.
Locale, if present, is expressed as a language, country, and
variant triplets, as understood by the LocaleParser
class. If locale setting is missing, system default locale will
be used.
Examples
setFormat in class FormatTypeformat - type specification string as described above (may be null)getFormat(),
FormatType.getFormatter(),
getStyle(),
LocaleParser,
LocaleType.setFormat(java.lang.String)public java.lang.Class getValueClass()
getValueClass in class FormatType
public DataValue toData(java.lang.Object objectValue)
throws InvalidDataException
The following object types are converted directly, others are converted first to strings, then to time values.
toData in class TypeobjectValue - data object
InvalidDataException - if given object value could not be parsedtoData(String,ParsePosition),
toData(java.util.Date),
CalendarData,
CalendarFieldData,
DateData,
TimeData,
TimestampData
public DataValue toData(java.lang.String stringValue,
java.text.ParsePosition status)
throws InvalidDataException
Timestamp type expects the given value to contain a timestamp string
compatible with current timestamp pattern, and returns a corresponding
TimestampData value.
toData in class TypestringValue - data stringstatus - parse status (may be null)
InvalidDataException - if given string value could not be parseddateValue(String,ParsePosition),
toData(java.util.Date),
toData(Object),
TimestampData
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||