Using the DATETIME type
When calling a Java method with an expression evaluating to a DATETIME
,
the runtime system converts the DATETIME
value to an instance
of the com.fourjs.fgl.lang.FglDateTime
class implemented in
$FGLDIR/lib/fgl.jar. You can then manipulate the
DATETIME
from within the Java code.
You must add $FGLDIR/lib/fgl.jar to the class path in
order to compile Java code with com.fourjs.fgl.lang.FglDateTime
class.
com.fourjs.fgl.lang.FglDateTime
class implements the
following:
Field | Description |
---|---|
|
Time qualifier for year |
|
Time qualifier for month |
|
Time qualifier for day |
|
Time qualifier for hour |
|
Time qualifier for minute |
|
Time qualifier for second |
|
Time qualifier for fraction (start qualifier) |
|
Time qualifier for fraction(1) (end qualifier) |
|
Time qualifier for fraction(2) (end qualifier) |
|
Time qualifier for fraction(3) (end qualifier) |
|
Time qualifier for fraction(4) (end qualifier) |
|
Time qualifier for fraction(5) (end qualifier) |
Method | Description |
---|---|
|
Returns the encoded type qualifier for a datetime with to datetime
qualifiers passed: encoded qualifier = (length * 256) + (startUnit * 16) + endUnit Where length defines the total number of significant digits in this time data. For example,
with startUnit = YEAR length = 12 (YYYYMMDDhhmm) endUnit = MINUTE |
|
Converts the DATETIME value
to a String object representing a datetime in the format YYYY-MM-DD
hh:mm:ss.fff . |
|
Creates a new |
|
Creates a new |
|
Creates a new FglDateTime object
from a String object representing a datetime value in the format YYYY-MM-DD
hh:mm:ss.fff , using the qualifiers passed as parameter. |
com.fourjs.fgl.lang.FglDateTime
to
a java.util.Calendar
object as in this
example:public static void useDatetime(FglDateTime dt) throws ParseException {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
Calendar cal = Calendar.getInstance();
cal.setTime( sdf.parse(dt.toString()) );
...
}
com.fourjs.fgl.lang.FglDateTime
object in your program,
you can use the valueOf()
class method as in this
example:IMPORT JAVA com.fourjs.fgl.lang.FglDateTime
MAIN
DEFINE dt com.fourjs.fgl.lang.FglDateTime
LET dt = FglDateTime.valueOf("2008-12-23 11:22:33.123")
LET dt = FglDateTime.valueOf("11:22:33.123",
FglDateTime.HOUR, FglDateTime.FRACTION3)
DISPLAY dt.toString()
END MAIN
The valueOf()
method expects a string representing
a complete date-time specification, from year to milliseconds,
equivalent to a DATETIME YEAR TO FRACTION(3)
data
type.