Date, Time, Timestamp, and TimestampOffset

You can represent database attribute types in JSON as string values. API Creator maps the various attributes to the following internal types:
lac40
You can represent database attribute types in JSON as string values. API Creator maps the various attributes to the following internal types:
  • SimpleDate
    class
  • SimpleTime
    class
  • SimpleTimestamp
     class
  • SimpleTimestampOffset
     class
You can reference these internal types in JavaScript code blocks in rules, resources, events, functions.
In this article:
Date Data Type
The
SimpleDate
class is an internal type. You can return year, month, day using this class. The following code snippet shows examples for the
Date
data type:
var SimpleDate = Java.type("com.kahuna.util.SimpleDate"); var mydate = new SimpleDate(2017,12,31); //year, month, day // mydate = SimpleDate.valueOf("2017-12-31"); // mydate = "2017-12-31"; // mydate = SimpleDate.fromJavaUtilDate(new Date());
Time Data Type
The
SimpleTime
class is an internal type. You can return hours, minutes, seconds, picos using this class. The following code snippet shows examples for the
Time
data type:
var SimpleTime = Java.type("com.kahuna.util.SimpleTime"); var st = new SimpleTime(12,59,59,123455678); //hours (1-24), minutes (0-59), seconds (0-59), picos // st = "12:59:59"; // st = SimpleTime.valueOf("12:59:59:12345678"); // st = SimpleTime.fromJavaUtilDate(new Date());
Timestamp Data Type
The
SimpleTimestamp
class is an internal type. You can return hours, minutes, seconds, picos, offset using this class. The following code snippet shows examples for the
timestamp
data type:
var SimpleTimestamp = Java.type("com.kahuna.util.SimpleTimestamp"); var sts = new SimpleTimestamp(2017,12,31,12,59,59,123456789); // sts = "2017-12-31T59:59:12345678"; // sts = SimpleTimestamp fromJavaUtilDate(new Date()); // sts = SimpleTimestamp.valueOf("2017-12-31T59:59:12345678");
TimestampOffset Data Type
The
SimpleTimestampOffset
class is an internal type. You can use this class to support databases that include an offset from Greenwich Mean Time (GMT). The syntax includes a positive/negative offset from GMT plus hours and seconds. The following code snippet shows examples for the
TimestampOffset
data type:
//valid format is [-]yyyy-mm-dd[ -tT]hh[-.:]mm[-.:]ss[-.:] [positive offset] [hours][minutes] var SimpleTimestampOffset = Java.type("com.kahuna.util.SimpleTimestampOffset"); var stso = new SimpleTimestampOffset(2017,12,31,12,59,59,false,5,0); //New York // stso = "2017-12-31T59:59:59.123456789123-0500"; // stso = "2017-12-31T59:59:59.123456789123-0500"; // stso = SimpleTimestampOffset.fromJavaUtilDate(new Date()); // stso = stso.asSimpleTimestampAdjusted(); // stso = SimpleTimestampOffset.valueOf("2017-12-31T59:59:59.123456789123-0500");