|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.mguennewig.pobjects.metadata.AbstractType
de.mguennewig.pobjects.metadata.ScalarType
de.mguennewig.pobjects.metadata.TimeStampType
public class TimeStampType
A time stamp stored as a decimal number, for example as a 14 digit
yyyyMMddHHmmss.
Please note that this format does not distinguish between summer and winter time, not knows anything about time zones.
SimpleDateFormat| Field Summary | |
|---|---|
static java.lang.String |
DEFAULT_FORMAT
The default data format used to display in the application. |
static java.lang.String |
DEFAULT_FORMAT_10
The data format for a precision of 10. |
static java.lang.String |
DEFAULT_FORMAT_12
The data format for a precision of 12. |
static java.lang.String |
DEFAULT_FORMAT_4
The data format for a precision of 4. |
static java.lang.String |
DEFAULT_FORMAT_6
The data format for a precision of 6. |
static java.lang.String |
DEFAULT_FORMAT_8
The data format for a precision of 8. |
static java.math.BigInteger |
NOT_BEFORE_NOW
Special lower limit to use the current time as lower limit. |
| Fields inherited from interface de.mguennewig.pobjects.metadata.Type |
|---|
CLASS_NAME, TYPE_NAME |
| Constructor Summary | |
|---|---|
TimeStampType(int precision)
Creates a new time stamp with the DEFAULT_FORMAT. |
|
TimeStampType(int precision,
java.lang.String format)
Creates a new time stamp without lower limit. |
|
TimeStampType(int precision,
java.lang.String format,
java.math.BigInteger lowerLimit)
Creates a new time stamp. |
|
| Method Summary | |
|---|---|
void |
checkConstraints(Record rec,
Column column)
Checks all constraints imposed on values of this type. |
java.lang.String |
formatDate(java.math.BigInteger value,
java.text.DateFormat formatter,
java.lang.String nullRepresentation)
Formats the value for the user interface using the system default timezone. |
java.lang.String |
formatDate(java.math.BigInteger value,
java.util.TimeZone valueTimeZone,
java.text.DateFormat formatter,
java.lang.String nullRepresentation)
Formats the value for the user interface. |
java.lang.String |
formatNative(java.lang.Object value)
Map value from its `native' string representation to its
internal representation based on the type. |
java.lang.String |
getFormat()
Returns the format string used to display the time stamp in the application. |
java.lang.Class<java.math.BigInteger> |
getJavaClass()
Returns the Java class instance that is being used for the values of this type. |
java.math.BigInteger |
getLowerLimit()
Returns the lower limit of valid time stamps. |
int |
getMaxFieldSize()
Returns the maximum field size required to enter a value of this type. |
int |
getPrecision()
Returns the count of digits totally allowed. |
java.math.BigInteger |
now()
Returns the time stamp for the current time and precision. |
java.lang.Object |
parse(java.lang.String value)
Map value to its internal representation. |
java.lang.Object |
parseNative(java.lang.String value)
Parse value according to the `native' string representation
of this type. |
void |
setParam(JdbcContainer db,
java.sql.PreparedStatement statm,
int pos,
java.lang.Object value)
Sets the parameter(s) starting at startPos. |
java.util.Date |
toDate(java.math.BigInteger timestamp)
Converts the time stamp to a Date instance. |
java.util.Date |
toDate(java.math.BigInteger value,
java.util.TimeZone timezone)
Converts the time stamp to a Date instance. |
java.math.BigInteger |
valueOf(java.util.Date date)
Converts the date to a time stamp using the system default timezone. |
java.math.BigInteger |
valueOf(java.util.Date date,
java.util.TimeZone timezone)
Converts the date to a time stamp. |
| Methods inherited from class de.mguennewig.pobjects.metadata.ScalarType |
|---|
addMap, checkSyntax, expand, getMap, getResult, getResultInc, isScalar, labelToValue, valueToLabel |
| Methods inherited from class de.mguennewig.pobjects.metadata.AbstractType |
|---|
format, getDescription, getTypeClass, name, setDescription, setTypeClass |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String DEFAULT_FORMAT
public static final java.lang.String DEFAULT_FORMAT_12
public static final java.lang.String DEFAULT_FORMAT_10
public static final java.lang.String DEFAULT_FORMAT_8
public static final java.lang.String DEFAULT_FORMAT_6
public static final java.lang.String DEFAULT_FORMAT_4
public static final java.math.BigInteger NOT_BEFORE_NOW
| Constructor Detail |
|---|
public TimeStampType(int precision)
DEFAULT_FORMAT.
public TimeStampType(int precision,
java.lang.String format)
public TimeStampType(int precision,
java.lang.String format,
java.math.BigInteger lowerLimit)
| Method Detail |
|---|
public final int getPrecision()
public final java.lang.String getFormat()
SimpleDateFormatpublic final java.math.BigInteger getLowerLimit()
null if no lower limit exists, the special value
NOT_BEFORE_NOW if only values in the future are valid, or the
appropriate time stamp.
public final java.lang.String formatDate(java.math.BigInteger value,
java.text.DateFormat formatter,
java.lang.String nullRepresentation)
value - The time stamp value.formatter - The date format to use.nullRepresentation - The string that should be used for a
null value.
java.lang.IllegalArgumentException - if format is invalid
or value does not represent a value of this type.formatDate(BigInteger,DateFormat,String),
formatNative(Object)
public final java.lang.String formatDate(java.math.BigInteger value,
java.util.TimeZone valueTimeZone,
java.text.DateFormat formatter,
java.lang.String nullRepresentation)
value - The time stamp value.valueTimeZone - Interpret the time stamp within this timezone. If
not given the system default timezone will be used.formatter - The date format to use.nullRepresentation - The string that should be used for a
null value.
java.lang.IllegalArgumentException - if format is invalid
or value does not represent a value of this type.public final java.math.BigInteger now()
Calendar.getTime(),
valueOf(Date)public final java.util.Date toDate(java.math.BigInteger timestamp)
Date instance.
java.lang.IllegalArgumentException - if format is invalid
or timestamp does not represent a value of this type.
public final java.util.Date toDate(java.math.BigInteger value,
java.util.TimeZone timezone)
Date instance.
value - The time stamp to convert.timezone - Interpret the time stamp within this timezone. If not
given the system default timezone is used.
java.lang.IllegalArgumentException - if format is invalid
or time stamp does not represent a value of this type.public final java.math.BigInteger valueOf(java.util.Date date)
public final java.math.BigInteger valueOf(java.util.Date date,
java.util.TimeZone timezone)
date - The date to convert to a time stamp of this type.timezone - Interpret the date in this timezone. If not given the
system default timezone is used.public final java.lang.Class<java.math.BigInteger> getJavaClass()
public int getMaxFieldSize()
This is the maximum number of characters required to enter a string representation of all valid values of this type. The typical size of an input field may be much smaller.
getMaxFieldSize in interface TypegetMaxFieldSize in class ScalarType
public void checkConstraints(Record rec,
Column column)
throws PObjConstraintException
checkConstraints in interface TypecheckConstraints in class ScalarTyperec - The record which contains column.column - The column of rec which has this type.
PObjConstraintException - when any constraint imposed on values of
this type is not fulfilled.public java.lang.String formatNative(java.lang.Object value)
value from its `native' string representation to its
internal representation based on the type.
This mapping is a one-to-one mapping of string values to the type's
value set, without any translation based on MapItems associated
with the type.
For example, an integer type's implementation would accept a value like `1' and translate it to the string `&dblquote;1&dblquote;', independent of any label associated with the value `1'.
The value null is always mapped to the empty string.
formatNative in interface TypeformatNative in class AbstractTypejava.lang.ClassCastException - if value is not a
BigInteger.
java.lang.IllegalArgumentException - if format is invalid
or value does not represent a value of this type.formatDate(BigInteger,DateFormat,String),
formatDate(BigInteger,TimeZone,DateFormat,String)
public java.lang.Object parseNative(java.lang.String value)
throws PObjSyntaxException
value according to the `native' string representation
of this type.
This representation is a one-to-one mapping of the type's value set to
strings, without any translation based on MapItems associated with
the type.
For example, an integer type's implementation would accept a value like `"1"' and translate it to an integer object, but would reject a label like `"Yes"' that may be associated with the value `1'.
PObjSyntaxException - if value couldn't be parsed as a
string representation of this type.Type.addMap(MapItem),
Type.parse(String)
public java.lang.Object parse(java.lang.String value)
throws PObjSyntaxException
value to its internal representation.
If value matches one of the labels associated with this
type, then it returns its associated value. Otherwise, delegates the job
to Type.parseNative(String).
Furthermore the syntax of the value is checked.
parse in interface Typeparse in class AbstractTypePObjSyntaxException - if value couldn't be parsed as a
string representation of this type.Type.addMap(MapItem),
Type.labelToValue(String,ObjectRef),
Type.checkSyntax(String),
Type.parseNative(String)
public void setParam(JdbcContainer db,
java.sql.PreparedStatement statm,
int pos,
java.lang.Object value)
throws java.sql.SQLException
startPos.
This method is the counterpart to
Type.getResult(JdbcContainer,ResultSet,int) and
Type.getResultInc().
java.sql.SQLException - if any database error occurs.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||