use of java.time.ZoneId in project dropwizard by dropwizard.
the class InstantArgumentTest method applyCalendar.
@Test
public void applyCalendar() throws Exception {
final ZoneId systemDefault = ZoneId.systemDefault();
// this test only asserts that a calendar was passed in. Not that the JDBC driver
// will do the right thing and adjust the time.
final ZonedDateTime zonedDateTime = ZonedDateTime.parse("2012-12-21T00:00:00.000Z");
final ZonedDateTime expected = zonedDateTime.withZoneSameInstant(systemDefault);
final Calendar calendar = new GregorianCalendar(TimeZone.getTimeZone(systemDefault));
new InstantArgument(zonedDateTime.toInstant(), Optional.of(calendar)).apply(1, statement, context);
Mockito.verify(statement).setTimestamp(1, Timestamp.from(expected.toInstant()), calendar);
}
use of java.time.ZoneId in project jetty.project by eclipse.
the class RolloverFileOutputStreamTest method testMidnightRolloverCalc_Sydney_DST_End.
@Test
public void testMidnightRolloverCalc_Sydney_DST_End() {
ZoneId zone = toZoneId("Australia/Sydney");
ZonedDateTime initialDate = toDateTime("2016.04.02-11:22:33.0 AM AEDT", zone);
ZonedDateTime midnight = RolloverFileOutputStream.toMidnight(initialDate, zone);
assertThat("Midnight", toString(midnight), is("2016.04.02-12:00:00.0 AM AEDT"));
Object[][] expected = { { "2016.04.03-12:00:00.0 AM AEDT", 86_400_000L }, // The long day
{ "2016.04.04-12:00:00.0 AM AEST", 90_000_000L }, { "2016.04.05-12:00:00.0 AM AEST", 86_400_000L }, { "2016.04.06-12:00:00.0 AM AEST", 86_400_000L }, { "2016.04.07-12:00:00.0 AM AEST", 86_400_000L } };
assertSequence(midnight, expected);
}
use of java.time.ZoneId in project jetty.project by eclipse.
the class RolloverFileOutputStreamTest method testMidnightRolloverCalc_PST_DST_Start.
@Test
public void testMidnightRolloverCalc_PST_DST_Start() {
ZoneId zone = toZoneId("PST");
ZonedDateTime initialDate = toDateTime("2016.03.11-01:23:45.0 PM PST", zone);
ZonedDateTime midnight = RolloverFileOutputStream.toMidnight(initialDate, zone);
assertThat("Midnight", toString(midnight), is("2016.03.11-12:00:00.0 AM PST"));
Object[][] expected = { { "2016.03.12-12:00:00.0 AM PST", 86_400_000L }, { "2016.03.13-12:00:00.0 AM PST", 86_400_000L }, // the short day
{ "2016.03.14-12:00:00.0 AM PDT", 82_800_000L }, { "2016.03.15-12:00:00.0 AM PDT", 86_400_000L }, { "2016.03.16-12:00:00.0 AM PDT", 86_400_000L } };
assertSequence(midnight, expected);
}
use of java.time.ZoneId in project jetty.project by eclipse.
the class RolloverFileOutputStreamTest method testMidnightRolloverCalc_PST_DST_End.
@Test
public void testMidnightRolloverCalc_PST_DST_End() {
ZoneId zone = toZoneId("PST");
ZonedDateTime initialDate = toDateTime("2016.11.04-11:22:33.0 AM PDT", zone);
ZonedDateTime midnight = RolloverFileOutputStream.toMidnight(initialDate, zone);
assertThat("Midnight", toString(midnight), is("2016.11.04-12:00:00.0 AM PDT"));
Object[][] expected = { { "2016.11.05-12:00:00.0 AM PDT", 86_400_000L }, { "2016.11.06-12:00:00.0 AM PDT", 86_400_000L }, // the long day
{ "2016.11.07-12:00:00.0 AM PST", 90_000_000L }, { "2016.11.08-12:00:00.0 AM PST", 86_400_000L }, { "2016.11.09-12:00:00.0 AM PST", 86_400_000L } };
assertSequence(midnight, expected);
}
use of java.time.ZoneId in project jdk8u_jdk by JetBrains.
the class TCKJapaneseChronology method test_dateNow.
//-----------------------------------------------------------------------
@Test
public void test_dateNow() {
assertEquals(JapaneseChronology.INSTANCE.dateNow(), JapaneseDate.now());
assertEquals(JapaneseChronology.INSTANCE.dateNow(), JapaneseDate.now(ZoneId.systemDefault()));
assertEquals(JapaneseChronology.INSTANCE.dateNow(), JapaneseDate.now(Clock.systemDefaultZone()));
assertEquals(JapaneseChronology.INSTANCE.dateNow(), JapaneseDate.now(Clock.systemDefaultZone().getZone()));
assertEquals(JapaneseChronology.INSTANCE.dateNow(), JapaneseChronology.INSTANCE.dateNow(ZoneId.systemDefault()));
assertEquals(JapaneseChronology.INSTANCE.dateNow(), JapaneseChronology.INSTANCE.dateNow(Clock.systemDefaultZone()));
assertEquals(JapaneseChronology.INSTANCE.dateNow(), JapaneseChronology.INSTANCE.dateNow(Clock.systemDefaultZone().getZone()));
ZoneId zoneId = ZoneId.of("Europe/Paris");
assertEquals(JapaneseChronology.INSTANCE.dateNow(zoneId), JapaneseChronology.INSTANCE.dateNow(Clock.system(zoneId)));
assertEquals(JapaneseChronology.INSTANCE.dateNow(zoneId), JapaneseChronology.INSTANCE.dateNow(Clock.system(zoneId).getZone()));
assertEquals(JapaneseChronology.INSTANCE.dateNow(zoneId), JapaneseDate.now(Clock.system(zoneId)));
assertEquals(JapaneseChronology.INSTANCE.dateNow(zoneId), JapaneseDate.now(Clock.system(zoneId).getZone()));
assertEquals(JapaneseChronology.INSTANCE.dateNow(ZoneId.of(ZoneOffset.UTC.getId())), JapaneseChronology.INSTANCE.dateNow(Clock.systemUTC()));
}
Aggregations