Data Types

Java API provides objects that correspond to DolphinDB data types. They are usually named as Basic+ <DataType>, such as BasicInt, BasicDate, etc.

Java Primitive Data Type Example Java API Data Type Example for Converting Java Primitive Type to Java API Type Example for Converting Java API Type to Java Primitive Type DolphinDB Data Type Example
Boolean Boolean var = true; BasicBoolean BasicBoolean basicBoolean = new BasicBoolean(true);

BasicBoolean basicBoolean = new BasicBoolean(true);

boolean value = basicBoolean.getBoolean();

BOOL 1b, 0b, true, false
Byte byte number = 10; BasicByte BasicByte basicByte = new BasicByte((byte) 13);

BasicByte basicByte = new BasicByte((byte) 13);

Byte value = basicByte.byteValue();

CHAR 'a', 97c
LocalDate LocalDate specificDate = LocalDate.of(2023, 6, 30); BasicDate BasicDate basicDate = new BasicDate(LocalDate.of(2021, 12, 9));

BasicDate basicDate = new BasicDate(LocalDate.of(2021, 12, 9));

LocalDate localDate = basicDate.getDate();

DATE 2023.06.13
Calendar

// create a Calendar object with specified date and time

specificCalendar = Calendar.getInstance();

specificCalendar.set(2023, Calendar.JUNE, 30, 12, 0, 0);

BasicDate BasicDate basicDate = new BasicDate(specificCalendar); - DATE 2023.06.13
same as above BasicDateHour

Calendar calendar = Calendar.getInstance();

calendar.set(2022,0,31,2,2,2);

BasicDateHour date = new BasicDateHour(calendar);

- DATEHOUR 2012.06.13T13
same as above BasicDateTime BasicDateTime basicDateTime = new BasicDateTime(new GregorianCalendar()); - DATETIME 2012.06.13 13:30:10 or 2012.06.13T13:30:10
same as above BasicTime BasicTime basicTime = new BasicTime(new GregorianCalendar()); - TIME 13:30:10.008
same as above BasicTimestamp BasicTimestamp basicTimestamp = new BasicTimestamp(new GregorianCalendar()); - TIMESTAMP 2012.06.13 13:30:10.008 or 2012.06.13T13:30:10.008
LocalDateTime LocalDateTime currentDateTime = LocalDateTime.now(); BasicDateHour BasicDateHour basicDateHour = new BasicDateHour(LocalDateTime.now());

BasicDateHour basicDateHour = new BasicDateHour(LocalDateTime.now());

LocalDateTime dateHour = basicDateHour.getDateHour();

DATEHOUR 2012.06.13T13
same as above BasicDateTime BasicDateTime basicDateTime = new BasicDateTime(LocalDateTime.of(2000, 2, 2, 3, 2, 3, 2));

BasicDateTime basicDateTime = new BasicDateTime(LocalDateTime.of(2000, 2, 2, 3, 2, 3, 2));

LocalDateTime dateTime = basicDateTime.getDateTime();

DATETIME 2012.06.13 13:30:10 or 2012.06.13T13:30:10
same as above BasicMinute BasicMinute basicMinute = new BasicMinute(LocalTime.of(11, 40, 53));

BasicMinute basicMinute = new BasicMinute(LocalTime.of(11, 40, 53));

LocalTime localTime = basicMinute.getMinute();

MINUTE 13:30m
same as above BasicNanoTime BasicNanoTime basicNanoTime = new BasicNanoTime(LocalDateTime.of(2000, 2, 2, 3, 2, 3, 2));

BasicNanoTime basicNanoTime = new BasicNanoTime(LocalDateTime.of(2000, 2, 2, 3, 2, 3, 2));

LocalTime localTime = basicNanoTime.getNanoTime();

NANOTIME 13:30:10.008007006
same as above BasicNanoTimestamp BasicNanoTimestamp bnts = new BasicNanoTimestamp(LocalDateTime.of(2018,11,12,8,1,1,123456789));

BasicNanoTimestamp bnts = new BasicNanoTimestamp(LocalDateTime.of(2018,11,12,8,1,1,123456789));

LocalDateTime localDateTime = bnts.getNanoTimestamp();

NANOTIMESTAMP 2012.06.13 13:30:10.008007006 or 2012.06.13T13:30:10.008007006
same as above BasicTimestamp BasicTimestamp basicTimestamp = new BasicTimestamp(LocalDateTime.of(2000, 2, 2, 3, 2, 3, 2));

BasicTimestamp basicTimestamp = new BasicTimestamp(LocalDateTime.of(2000, 2, 2, 3, 2, 3, 2));

LocalDateTime localDateTime = basicTimestamp.getTimestamp();

TIMESTAMP 2012.06.13 13:30:10.008 or 2012.06.13T13:30:10.008
String String decimalValue = "3.1415926"; BasicDecimal32

String decimalValue = "3.1415926";

BasicDecimal32 basicDecimal32 = new BasicDecimal32(decimalValue, 3);

String decimalValue = "3.1415926";

BasicDecimal32 basicDecimal32 = new BasicDecimal32(decimalValue, 3);

basicDecimal32.getString();

DECIMAL32(S) 3.1415926$DECIMAL32(3)
String String decimalValue = "3.1415926"; BasicDecimal64

String decimalValue = "3.1415926";

BasicDecimal64 basicDecimal64 = new BasicDecimal64(decimalValue, 3);

String decimalValue = "3.1415926";

BasicDecimal64 basicDecimal64 = new BasicDecimal64(decimalValue, 3);

basicDecimal64.getString();

DECIMAL64(S) 3.1415926$DECIMAL64(3), , 3.141P
String String decimalValue = "3.1415926"; BasicDecimal128

String decimalValue = "3.1415926";

BasicDecimal128 basicDecimal128 = new BasicDecimal128(decimalValue, 3);

String decimalValue = "3.1415926";

BasicDecimal128 basicDecimal128 = new BasicDecimal128(decimalValue, 3);

basicDecimal128.getString();

DECIMAL128(S)
Double Double number = Double.valueOf(3.14); BasicDouble BasicDouble basicDouble = new BasicDouble(15.48);

BasicDouble basicDouble = new BasicDouble(15.48);

double doubleValue = basicDouble.getDouble();

DOUBLE 15.48
- - BasicDuration BasicDuration basicDuration = new BasicDuration(Entity.DURATION.SECOND, 1); - DURATION 1s, 3M, 5y, 200ms
Float Float number = Float.valueOf(3.14f) BasicFloat BasicFloat basicFloat = new BasicFloat(2.1f);

BasicFloat basicFloat = new BasicFloat(2.1f);

float floatValue = basicFloat.getFloat();

FLOAT 2.1f
Integer Integer number = 1; BasicInt BasicInt basicInt = new BasicInt(1);

BasicInt basicInt = new BasicInt(1);

int intValue = basicInt.getInt();

INT 1
- - BasicInt128 BasicInt128 basicInt128 = BasicInt128.fromString("e1671797c52e15f763380b45e841ec32"); - INT128 e1671797c52e15f763380b45e841ec32
- - BasicIPAddr BasicIPAddr basicIPAddr = BasicIPAddr.fromString("192.168.1.13"); - IPADDR 192.168.1.13
Long Long number = 123456789L; BasicLong BasicLong basicLong = new BasicLong(367);

BasicLong basicLong = new BasicLong(367);

long longValue = basicLong.getLong();

LONG 367l
YearMonth YearMonth yearMonth = YearMonth.of(2023, 6); BasicMonth BasicMonth basicMonth = new BasicMonth(YearMonth.of(2022, 7));

BasicMonth basicMonth = new BasicMonth(YearMonth.of(2022, 7));

YearMonth yearMonth = basicMonth.getMonth();

MONTH 2012.06M
LocalTime LocalTime specificTime = LocalTime.of(10, 30, 0); BasicNanoTime BasicNanoTime basicNanoTime = new BasicNanoTime(LocalTime.of(1, 1, 1, 1323433));

BasicNanoTime basicNanoTime = new BasicNanoTime(LocalTime.of(1, 1, 1, 1323433));

LocalTime nanoTime = basicNanoTime.getNanoTime();

NANOTIME 13:30:10.008007006
same as above BasicSecond BasicSecond basicSecond = new BasicSecond(LocalTime.of(2, 2, 2));

BasicSecond basicSecond = new BasicSecond(LocalTime.of(2, 2, 2));

LocalTime localTime = basicSecond.getSecond();

SECOND 13:30:10
same as above BasicTime BasicTime basicTime = new BasicTime(LocalTime.of(13, 7, 55));

BasicTime basicTime = new BasicTime(LocalTime.of(13, 7, 55));

LocalTime localTime = basicTime.getTime();

TIME 13:30:10.008
- - BasicPoint BasicPoint basicPoint = new BasicPoint(6.4, 9.2); - POINT (117.60972, 24.118418)
short short number = 100; BasicShort BasicShort basicShort = new BasicShort((short) 21);

BasicShort basicShort = new BasicShort((short) 21);

short shortValue = basicShort.getShort();

SHORT 122h
String String s = "abcd"; BasicString BasicString basicString = new BasicString("colDefs");

BasicString basicString = new BasicString("Hello");

String stringValue = basicString.getString();

STRING "Hello" or 'Hello' or `Hello
- - BasicString BasicString basicString = new BasicString("Jmeter", true); - BLOB -
UUID UUID uuid = UUID.randomUUID(); BasicUuid

BasicUuid.fromString("5d212a78-cc48-e3b1-4235-b4d91473ee87")

UUID uuid = UUID.randomUUID();

BasicUuid basicUuid = BasicUuid.fromString(uuid.toString());

BasicUuid basicUuid = BasicUuid.fromString("5d212a78-cc48-e3b1-4235-b4d91473ee87");

UUID uuid = UUID.fromString(basicUuid.getString());

UUID 5d212a78-cc48-e3b1-4235-b4d91473ee87