use of java.time.ZoneId in project assertj-core by joel-costigliola.
the class ZonedDateTimeAssert_isNotIn_Test method isNotIn_should_compare_datetimes_in_actual_timezone.
@Test
public void isNotIn_should_compare_datetimes_in_actual_timezone() {
ZonedDateTime utcDateTime = ZonedDateTime.of(2013, 6, 10, 0, 0, 0, 0, ZoneOffset.UTC);
ZoneId cestTimeZone = ZoneId.of("Europe/Berlin");
ZonedDateTime cestDateTime = ZonedDateTime.of(2013, 6, 10, 0, 0, 0, 0, cestTimeZone);
// cestDateTime and utcDateTime are not equals in same timezone
assertThat(utcDateTime).isNotIn(cestDateTime, ZonedDateTime.now());
}
use of java.time.ZoneId in project junit5 by junit-team.
the class XmlReportsWritingListenerTests method writesHostNameAndTimestamp.
@Test
void writesHostNameAndTimestamp(@Root Path tempDirectory) throws Exception {
DemoHierarchicalTestEngine engine = new DemoHierarchicalTestEngine("dummy");
engine.addTest("test", () -> {
});
LocalDateTime now = LocalDateTime.parse("2016-01-28T14:02:59.123");
ZoneId zone = ZoneId.systemDefault();
executeTests(engine, tempDirectory, Clock.fixed(ZonedDateTime.of(now, zone).toInstant(), zone));
String content = readValidXmlFile(tempDirectory.resolve("TEST-dummy.xml"));
// @formatter:off
assertThat(content).containsSubsequence("<testsuite", "hostname=\"" + InetAddress.getLocalHost().getHostName() + "\"", "timestamp=\"2016-01-28T14:02:59\"", "<testcase", "</testsuite>");
// @formatter:on
}
use of java.time.ZoneId in project spf4j by zolyfarkas.
the class QuantizedXYZDatasetImpl method createXTickUnits.
public TickUnits createXTickUnits() {
TickUnits tux = new TickUnits();
if (data.length == 0) {
return tux;
}
ZoneId systemDefault = ZoneId.systemDefault();
final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd'T'HH:mm:ss").withZone(systemDefault);
final DateTimeFormatter shortFormat = DateTimeFormatter.ofPattern("yyyyMMdd'T'HH").withZone(systemDefault);
final DateTimeFormatter mediumFormat = DateTimeFormatter.ofPattern("yyyyMMdd'T'HH:mm").withZone(systemDefault);
final long[] timestamps = new long[data[0].length];
long time = startTimeMillis;
for (int i = 0; i < timestamps.length; i++) {
timestamps[i] = time;
time += stepMillis;
}
// base
tux.add(new TimestampTickUnitImpl(1, timestamps, stepMillis, formatter));
long nr = 5000L / stepMillis;
if (nr > 1) {
tux.add(new TimestampTickUnitImpl(nr, timestamps, stepMillis, formatter));
}
nr = 15000L / stepMillis;
if (nr > 1) {
tux.add(new TimestampTickUnitImpl(nr, timestamps, stepMillis, formatter));
}
// minute
nr = 60000L / stepMillis;
if (nr > 1) {
tux.add(new TimestampTickUnitImpl(nr, timestamps, stepMillis, mediumFormat));
}
// 15 minute
nr = 900000L / stepMillis;
if (nr > 1) {
tux.add(new TimestampTickUnitImpl(nr, timestamps, stepMillis, mediumFormat));
}
// hour
nr = 3600000L / stepMillis;
if (nr > 1) {
tux.add(new TimestampTickUnitImpl(nr, timestamps, stepMillis, shortFormat));
}
// 6 hour
nr = 21600000L / stepMillis;
if (nr > 1) {
tux.add(new TimestampTickUnitImpl(nr, timestamps, stepMillis, shortFormat));
}
return tux;
}
use of java.time.ZoneId in project uhgroupings by uhawaii-system-its-ti-iam.
the class Dates method toLocalDate.
public static LocalDate toLocalDate(Date date) {
Date result = new Date();
try {
if (date instanceof java.sql.Date) {
result.setTime(date.getTime());
}
Instant instant = date.toInstant();
ZoneId zoneId = zoneId();
ZonedDateTime zoneDateTime = instant.atZone(zoneId);
return zoneDateTime.toLocalDate();
} catch (ClassCastException e) {
System.err.println(e.getMessage());
}
return null;
}
use of java.time.ZoneId in project dbflute-core by dbflute.
the class DfTypeUtil method doParseLocalDateTimeAsTimestamp.
protected static Timestamp doParseLocalDateTimeAsTimestamp(LocalDateTime localDateTime, TimeZone timeZone) {
if (localDateTime == null) {
return null;
}
final TimeZone realZone = chooseRealZone(timeZone);
final ZoneId zoneId = timeZone != null ? realZone.toZoneId() : ZoneId.systemDefault();
return Timestamp.from(localDateTime.toInstant(zoneId.getRules().getOffset(localDateTime)));
}
Aggregations