数据类型

下表罗列了 Java 原生数据类型、Java API 中定义的数据类型与 DolphinDB 中定义的数据类型的对应关系,以及构造数据和转换数据的示例。

Java 原生类型Java 原生类型示例数据Java API 类型Java 原生类型构造 Java API 类型示例数据Java API 类型转为 Java 原生类型示例DolphinDB 类型DolphinDB 示例数据
BooleanBoolean var = true;BasicBooleanBasicBoolean basicBoolean = new BasicBoolean(true);BasicBoolean basicBoolean = new BasicBoolean(true); boolean value = basicBoolean.getBoolean();BOOL1b, 0b, true, false
Bytebyte number = 10;BasicByteBasicByte basicByte = new BasicByte((byte) 13);BasicByte basicByte = new BasicByte((byte) 13); Byte value = basicByte.byteValue();CHAR‘a’, 97c
LocalDateLocalDate specificDate = LocalDate.of(2023, 6, 30);BasicDateBasicDate basicDate = new BasicDate(LocalDate.of(2021, 12, 9));BasicDate basicDate = new BasicDate(LocalDate.of(2021, 12, 9)); LocalDate localDate = basicDate.getDate();DATE2023.06.13
Calendar// 创建指定日期和时间的 Calendar 对象 Calendar specificCalendar = Calendar.getInstance(); specificCalendar.set(2023, Calendar.JUNE, 30, 12, 0, 0);BasicDateBasicDate basicDate = new BasicDate(specificCalendar);-DATE2023.06.13
同上BasicDateHourCalendar calendar = Calendar.getInstance(); calendar.set(2022,0,31,2,2,2); BasicDateHour date = new BasicDateHour(calendar);-DATEHOUR2012.06.13T13
同上BasicDateTimeBasicDateTime basicDateTime = new BasicDateTime(new GregorianCalendar());-DATETIME2012.06.13 13:30:10 or 2012.06.13T13:30:10
同上BasicMinuteBasicMinute basicMinute = new BasicMinute(new GregorianCalendar());-MINUTE13:30m
同上BasicTimeBasicTime basicTime = new BasicTime(new GregorianCalendar());-TIME13:30:10.008
同上BasicTimestampBasicTimestamp basicTimestamp = new BasicTimestamp(new GregorianCalendar());-TIMESTAMP2012.06.13 13:30:10.008 or 2012.06.13T13:30:10.008
LocalDateTimeLocalDateTime currentDateTime = LocalDateTime.now();BasicDateHourBasicDateHour basicDateHour = new BasicDateHour(LocalDateTime.now());BasicDateHour basicDateHour = new BasicDateHour(LocalDateTime.now()); LocalDateTime dateHour = basicDateHour.getDateHour();DATEHOUR2012.06.13T13
同上BasicDateTimeBasicDateTime 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();DATETIME2012.06.13 13:30:10 or 2012.06.13T13:30:10
同上BasicMinuteBasicMinute basicMinute = new BasicMinute(LocalTime.of(11, 40, 53));BasicMinute basicMinute = new BasicMinute(LocalTime.of(11, 40, 53)); LocalTime localTime = basicMinute.getMinute();MINUTE13:30m
同上BasicNanoTimeBasicNanoTime 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();NANOTIME13:30:10.008007006
同上BasicNanoTimestampBasicNanoTimestamp 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();NANOTIMESTAMP2012.06.13 13:30:10.008007006 or 2012.06.13T13:30:10.008007006
同上BasicTimestampBasicTimestamp 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();TIMESTAMP2012.06.13 13:30:10.008 or 2012.06.13T13:30:10.008
String (注:Java API 目前是通过(也推荐) String 来构造 decimal32/64/128)String decimalValue = "3.1415926";BasicDecimal32String 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)
StringString decimalValue = "3.1415926";BasicDecimal64String 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
StringString decimalValue = "3.1415926";BasicDecimal128String decimalValue = "3.1415926"; BasicDecimal128 basicDecimal128 = new BasicDecimal128(decimalValue, 3);String decimalValue = "3.1415926"; BasicDecimal128 basicDecimal128 = new BasicDecimal128(decimalValue, 3); basicDecimal128.getString();DECIMAL128(S)
DoubleDouble number = Double.valueOf(3.14);BasicDoubleBasicDouble basicDouble = new BasicDouble(15.48);BasicDouble basicDouble = new BasicDouble(15.48); double doubleValue = basicDouble.getDouble();DOUBLE15.48
--BasicDurationBasicDuration basicDuration = new BasicDuration(Entity.DURATION.SECOND, 1);-DURATION1s, 3M, 5y, 200ms
FloatFloat number = Float.valueOf(3.14f)BasicFloatBasicFloat basicFloat = new BasicFloat(2.1f);BasicFloat basicFloat = new BasicFloat(2.1f); float floatValue = basicFloat.getFloat();FLOAT2.1f
IntegerInteger number = 1;BasicIntBasicInt basicInt = new BasicInt(1);BasicInt basicInt = new BasicInt(1); int intValue = basicInt.getInt();INT1
--BasicInt128BasicInt128 basicInt128 = BasicInt128.fromString("e1671797c52e15f763380b45e841ec32");-INT128e1671797c52e15f763380b45e841ec32
--BasicIPAddrBasicIPAddr basicIPAddr = BasicIPAddr.fromString("192.168.1.13");-IPADDR192.168.1.13
LongLong number = 123456789L;BasicLongBasicLong basicLong = new BasicLong(367);BasicLong basicLong = new BasicLong(367); long longValue = basicLong.getLong();LONG367l
YearMonthYearMonth yearMonth = YearMonth.of(2023, 6);BasicMonthBasicMonth basicMonth = new BasicMonth(YearMonth.of(2022, 7));BasicMonth basicMonth = new BasicMonth(YearMonth.of(2022, 7)); YearMonth yearMonth = basicMonth.getMonth();MONTH2012.06M
LocalTimeLocalTime specificTime = LocalTime.of(10, 30, 0);BasicNanoTimeBasicNanoTime basicNanoTime = new BasicNanoTime(LocalTime.of(1, 1, 1, 1323433));BasicNanoTime basicNanoTime = new BasicNanoTime(LocalTime.of(1, 1, 1, 1323433)); LocalTime nanoTime = basicNanoTime.getNanoTime();NANOTIME13:30:10.008007006
同上BasicSecondBasicSecond basicSecond = new BasicSecond(LocalTime.of(2, 2, 2));BasicSecond basicSecond = new BasicSecond(LocalTime.of(2, 2, 2)); LocalTime localTime = basicSecond.getSecond();SECOND13:30:10
同上BasicTimeBasicTime basicTime = new BasicTime(LocalTime.of(13, 7, 55));BasicTime basicTime = new BasicTime(LocalTime.of(13, 7, 55)); LocalTime localTime = basicTime.getTime();TIME13:30:10.008
--BasicPointBasicPoint basicPoint = new BasicPoint(6.4, 9.2);-POINT(117.60972, 24.118418)
shortshort number = 100;BasicShortBasicShort basicShort = new BasicShort((short) 21);BasicShort basicShort = new BasicShort((short) 21); short shortValue = basicShort.getShort();SHORT122h
StringString s = “abcd“;BasicStringBasicString basicString = new BasicString("Hello");BasicString basicString = new BasicString("Hello"); String stringValue = basicString.getString();STRING“Hello” or ‘Hello’ or `Hello
--BasicStringBasicString basicString = new BasicString("Jmeter", true);-BLOB-
UUIDUUID uuid = UUID.randomUUID();BasicUuidBasicUuid.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());UUID5d212a78-cc48-e3b1-4235-b4d91473ee87

注:“-“ 表示暂无此对应的内容。