java.time.OffsetDateTime#atZoneSameInstant ( )源码实例Demo

下面列出了java.time.OffsetDateTime#atZoneSameInstant ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: cuba   文件: OffsetDateTimeDatatype.java
@Override
public String format(@Nullable Object value, Locale locale, TimeZone timeZone) {
    if (timeZone == null || value == null) {
        return format(value, locale);
    }
    OffsetDateTime offsetDateTime = (OffsetDateTime) value;
    ZonedDateTime zonedDateTime = offsetDateTime.atZoneSameInstant(timeZone.toZoneId());
    return format(zonedDateTime, locale);
}
 
源代码2 项目: sfg-blog-posts   文件: DateConverterImpl.java
public ZonedDateTime convertToAtZoneSameInstant() {
    OffsetDateTime offsetDateTime = OffsetDateTime.now();
    ZonedDateTime zonedDateTime2 = offsetDateTime.atZoneSameInstant(zoneId);
    System.out.println(zonedDateTime2);
    return zonedDateTime2;
}
 
源代码3 项目: dragonwell8_jdk   文件: TCKOffsetDateTime.java
@Test(expectedExceptions=NullPointerException.class)
public void test_atZone_nullTimeZone() {
    OffsetDateTime t = OffsetDateTime.of(2008, 6, 30, 11, 30, 0, 0, OFFSET_PTWO);
    t.atZoneSameInstant((ZoneId) null);
}
 
源代码4 项目: TencentKona-8   文件: TCKOffsetDateTime.java
@Test(expectedExceptions=NullPointerException.class)
public void test_atZone_nullTimeZone() {
    OffsetDateTime t = OffsetDateTime.of(2008, 6, 30, 11, 30, 0, 0, OFFSET_PTWO);
    t.atZoneSameInstant((ZoneId) null);
}
 
源代码5 项目: jdk8u60   文件: TCKOffsetDateTime.java
@Test(expectedExceptions=NullPointerException.class)
public void test_atZone_nullTimeZone() {
    OffsetDateTime t = OffsetDateTime.of(2008, 6, 30, 11, 30, 0, 0, OFFSET_PTWO);
    t.atZoneSameInstant((ZoneId) null);
}
 
源代码6 项目: pxf   文件: ParquetResolverTest.java
@Test
public void testGetFields_Primitive_Repeated_Synthetic() {
    // this test does not read the actual Parquet file, but rather construct Group object synthetically
    schema = getParquetSchemaForPrimitiveTypes(Type.Repetition.REPEATED, true);
    // schema has changed, set metadata again
    context.setMetadata(schema);
    context.setTupleDescription(getColumnDescriptorsFromSchema(schema));
    resolver.initialize(context);

    /*
    Corresponding DB column types  are:
    TEXT,TEXT,INTEGER, DOUBLE PRECISION,NUMERIC,TIMESTAMP,REAL,BIGINT,BOOLEAN,SMALLINT,SMALLINT,VARCHAR(5),CHAR(3),BYTEA
     */

    Group group = new SimpleGroup(schema);

    group.add(0, "row1-1");
    group.add(0, "row1-2");

    // leave column 1 (t2) unset as part fo the test

    group.add(2, 1);
    group.add(2, 2);
    group.add(2, 3);

    group.add(3, 6.0d);
    group.add(3, -16.34d);

    BigDecimal value = new BigDecimal("12345678.9012345987654321"); // place of dot doesn't matter
    byte fillByte = (byte) (value.signum() < 0 ? 0xFF : 0x00);
    byte[] unscaled = value.unscaledValue().toByteArray();
    byte[] bytes = new byte[16];
    int offset = bytes.length - unscaled.length;
    for (int i = 0; i < bytes.length; i += 1) {
        bytes[i] = (i < offset) ? fillByte : unscaled[i - offset];
    }
    group.add(4, Binary.fromReusedByteArray(bytes));

    group.add(5, ParquetTypeConverter.getBinaryFromTimestamp("2019-03-14 14:10:28"));
    group.add(5, ParquetTypeConverter.getBinaryFromTimestamp("1969-12-30 05:42:23.211211"));

    group.add(6, 7.7f);
    group.add(6, -12345.35354646f);

    group.add(7, 23456789L);
    group.add(7, -123456789012345L);

    group.add(8, true);
    group.add(8, false);

    group.add(9, (short) 1);
    group.add(9, (short) -3);

    group.add(10, (short) 269);
    group.add(10, (short) -313);

    group.add(11, Binary.fromString("Hello"));
    group.add(11, Binary.fromString("World"));

    group.add(12, Binary.fromString("foo"));
    group.add(12, Binary.fromString("bar"));

    byte[] byteArray1 = new byte[]{(byte) 49, (byte) 50, (byte) 51};
    group.add(13, Binary.fromReusedByteArray(byteArray1, 0, 3));
    byte[] byteArray2 = new byte[]{(byte) 52, (byte) 53, (byte) 54};
    group.add(13, Binary.fromReusedByteArray(byteArray2, 0, 3));

    group.add(14, ParquetTypeConverter.getBinaryFromTimestampWithTimeZone("2019-03-14 14:10:28+07"));
    OffsetDateTime offsetDateTime1 = OffsetDateTime.parse("2019-03-14T14:10:28+07:00");
    ZonedDateTime localDateTime1 = offsetDateTime1.atZoneSameInstant(ZoneId.systemDefault());
    String localDateTimeString1 = localDateTime1.format(DateTimeFormatter.ofPattern("[yyyy-MM-dd HH:mm:ss]"));

    group.add(15, ParquetTypeConverter.getBinaryFromTimestampWithTimeZone("2019-03-14 14:10:28-07:30"));
    OffsetDateTime offsetDateTime2 = OffsetDateTime.parse("2019-03-14T14:10:28-07:30");
    ZonedDateTime localDateTime2 = offsetDateTime2.atZoneSameInstant(ZoneId.systemDefault());
    String localDateTimeString2 = localDateTime2.format(DateTimeFormatter.ofPattern("[yyyy-MM-dd HH:mm:ss]"));


    List<Group> groups = new ArrayList<>();
    groups.add(group);
    List<OneField> fields = assertRow(groups, 0, 16);

    assertField(fields, 0, "[\"row1-1\",\"row1-2\"]", DataType.TEXT);
    assertField(fields, 1, "[]", DataType.TEXT);
    assertField(fields, 2, "[1,2,3]", DataType.TEXT);
    assertField(fields, 3, "[6.0,-16.34]", DataType.TEXT);
    assertField(fields, 4, "[123456.789012345987654321]", DataType.TEXT); // scale fixed to 18 in schema
    assertField(fields, 5, "[\"2019-03-14 14:10:28\",\"1969-12-30 05:42:23.211211\"]", DataType.TEXT);
    assertField(fields, 6, "[7.7,-12345.354]", DataType.TEXT); // rounded to the precision of 8
    assertField(fields, 7, "[23456789,-123456789012345]", DataType.TEXT);
    assertField(fields, 8, "[true,false]", DataType.TEXT);
    assertField(fields, 9, "[1,-3]", DataType.TEXT);
    assertField(fields, 10, "[269,-313]", DataType.TEXT);
    assertField(fields, 11, "[\"Hello\",\"World\"]", DataType.TEXT);
    assertField(fields, 12, "[\"foo\",\"bar\"]", DataType.TEXT); // 3 chars only
    Base64.Encoder encoder = Base64.getEncoder(); // byte arrays are Base64 encoded into strings
    String expectedByteArrays = "[\"" + encoder.encodeToString(byteArray1) + "\",\"" + encoder.encodeToString(byteArray2) + "\"]";
    assertField(fields, 13, expectedByteArrays, DataType.TEXT);
    assertField(fields, 14, "[\"" + localDateTimeString1 + "\"]", DataType.TEXT);
    assertField(fields, 15, "[\"" + localDateTimeString2 + "\"]", DataType.TEXT);
}
 
源代码7 项目: openjdk-jdk8u   文件: TCKOffsetDateTime.java
@Test(expectedExceptions=NullPointerException.class)
public void test_atZone_nullTimeZone() {
    OffsetDateTime t = OffsetDateTime.of(2008, 6, 30, 11, 30, 0, 0, OFFSET_PTWO);
    t.atZoneSameInstant((ZoneId) null);
}
 
源代码8 项目: openjdk-jdk8u-backup   文件: TCKOffsetDateTime.java
@Test(expectedExceptions=NullPointerException.class)
public void test_atZone_nullTimeZone() {
    OffsetDateTime t = OffsetDateTime.of(2008, 6, 30, 11, 30, 0, 0, OFFSET_PTWO);
    t.atZoneSameInstant((ZoneId) null);
}
 
源代码9 项目: openjdk-jdk9   文件: TCKOffsetDateTime.java
@Test(expectedExceptions=NullPointerException.class)
public void test_atZone_nullTimeZone() {
    OffsetDateTime t = OffsetDateTime.of(2008, 6, 30, 11, 30, 0, 0, OFFSET_PTWO);
    t.atZoneSameInstant((ZoneId) null);
}
 
源代码10 项目: jdk8u-jdk   文件: TCKOffsetDateTime.java
@Test(expectedExceptions=NullPointerException.class)
public void test_atZone_nullTimeZone() {
    OffsetDateTime t = OffsetDateTime.of(2008, 6, 30, 11, 30, 0, 0, OFFSET_PTWO);
    t.atZoneSameInstant((ZoneId) null);
}
 
源代码11 项目: hottub   文件: TCKOffsetDateTime.java
@Test(expectedExceptions=NullPointerException.class)
public void test_atZone_nullTimeZone() {
    OffsetDateTime t = OffsetDateTime.of(2008, 6, 30, 11, 30, 0, 0, OFFSET_PTWO);
    t.atZoneSameInstant((ZoneId) null);
}
 
源代码12 项目: openjdk-8-source   文件: TCKOffsetDateTime.java
@Test(expectedExceptions=NullPointerException.class)
public void test_atZone_nullTimeZone() {
    OffsetDateTime t = OffsetDateTime.of(2008, 6, 30, 11, 30, 0, 0, OFFSET_PTWO);
    t.atZoneSameInstant((ZoneId) null);
}
 
源代码13 项目: openjdk-8   文件: TCKOffsetDateTime.java
@Test(expectedExceptions=NullPointerException.class)
public void test_atZone_nullTimeZone() {
    OffsetDateTime t = OffsetDateTime.of(2008, 6, 30, 11, 30, 0, 0, OFFSET_PTWO);
    t.atZoneSameInstant((ZoneId) null);
}
 
源代码14 项目: jdk8u_jdk   文件: TCKOffsetDateTime.java
@Test(expectedExceptions=NullPointerException.class)
public void test_atZone_nullTimeZone() {
    OffsetDateTime t = OffsetDateTime.of(2008, 6, 30, 11, 30, 0, 0, OFFSET_PTWO);
    t.atZoneSameInstant((ZoneId) null);
}
 
源代码15 项目: jdk8u-jdk   文件: TCKOffsetDateTime.java
@Test(expectedExceptions=NullPointerException.class)
public void test_atZone_nullTimeZone() {
    OffsetDateTime t = OffsetDateTime.of(2008, 6, 30, 11, 30, 0, 0, OFFSET_PTWO);
    t.atZoneSameInstant((ZoneId) null);
}
 
源代码16 项目: jdk8u-dev-jdk   文件: TCKOffsetDateTime.java
@Test(expectedExceptions=NullPointerException.class)
public void test_atZone_nullTimeZone() {
    OffsetDateTime t = OffsetDateTime.of(2008, 6, 30, 11, 30, 0, 0, OFFSET_PTWO);
    t.atZoneSameInstant((ZoneId) null);
}
 
源代码17 项目: j2objc   文件: TCKOffsetDateTime.java
@Test(expected=NullPointerException.class)
public void test_atZone_nullTimeZone() {
    OffsetDateTime t = OffsetDateTime.of(2008, 6, 30, 11, 30, 0, 0, OFFSET_PTWO);
    t.atZoneSameInstant((ZoneId) null);
}