List of usage examples for java.time ZoneId systemDefault
public static ZoneId systemDefault()
From source file:example.springdata.cassandra.java8.Jsr310IntegrationTests.java
@Test public void findOneByJsr310Types() { Order order = new Order("42", LocalDate.now(), ZoneId.systemDefault()); repository.save(order);/* www . ja v a 2 s . c o m*/ assertThat(repository.findOrderByOrderDateAndZoneId(order.getOrderDate(), order.getZoneId()), is(equalTo(order))); }
From source file:com.orange.clara.tool.schedulers.SchedulerWatchedResources.java
@Scheduled(fixedDelay = 5000) public void refreshResource() throws AsyncTaskException { logger.debug("Running: refresh watched resource scheduled task ..."); Iterable<WatchedResource> watchedResources = this.watchedResourceRepo.findAll(); LocalDateTime whenRemoveDateTime; for (WatchedResource watchedResource : watchedResources) { if (watchedResource.getUpdatedResourceAt() == null) { continue; }//from w w w. jav a 2 s . co m whenRemoveDateTime = LocalDateTime .from(watchedResource.getUpdatedResourceAt().toInstant().atZone(ZoneId.systemDefault())) .plusMinutes(updateAfterMinutes); if (LocalDateTime.from(Calendar.getInstance().toInstant().atZone(ZoneId.systemDefault())) .isBefore(whenRemoveDateTime) || watchedResource.isLocked()) { continue; } watchedResource.setLocked(true); this.watchedResourceRepo.save(watchedResource); this.refreshTask.runTask(watchedResource.getId()); } logger.debug("Finished: refresh watched resource scheduled task."); }
From source file:edu.usu.sdl.openstorefront.common.util.TimeUtil.java
/** * Get the end of the day passed in/*from ww w . ja v a 2 s . co m*/ * * @param date * @return end of the day or null if date was null */ public static Date endOfDay(Date date) { if (date != null) { Instant instant = Instant.ofEpochMilli(date.getTime()); LocalDateTime localDateTime = LocalDateTime.ofInstant(instant, ZoneId.systemDefault()); localDateTime = localDateTime.withHour(23).withMinute(59).withSecond(59) .with(ChronoField.MILLI_OF_SECOND, 999); return new Date(localDateTime.toInstant(ZoneOffset.UTC).toEpochMilli()); } return date; }
From source file:no.asgari.civilization.server.model.Chat.java
@JsonIgnore public long getCreatedInMillis() { return created.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(); }
From source file:com.chadekin.jadys.syntax.SqlNativeQuerySectionDetailedITest.java
@Test public void shouldBuildAllSqlQuerySection() { // Arrange// w w w. j a v a 2 s . c o m Calendar calendar = Calendar.getInstance(); LocalDate localDate = LocalDate.of(2016, Month.DECEMBER, 14); Date date = Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant()); String internalSql = DynamicSqlFactory.newQuery().select("cus.Id_").count("*", "cus.numberOfLocation") .from("dct_customer").as("cus").join("dct_location", "loc").on("loc.customerId").equal("cus.id_") .where("cus.companyId").equal(142576).and("cus.customerId").equal(1258).and("cus.customerName") .like("BSD GmbH").and("zipCode").like(StringUtils.EMPTY).and("cus.city").like("Paris") .and("country").like(null).and("cus.externalId").like("456753").and("cus.customerType") .like(CustomerType.KEY_ACCOUNT).and("cus.modifiedDate").greaterThanOrEqual("2016-10-14") .and("cus.modifiedDate").lessThanOrEqual(date).and("cus.modifiedByUserId") .in(Lists.newArrayList(125, 36, 587)).groupBy("loc.customerId").having("COUNT(loc.customerId)") .equal(2).orderBy("cus.externalId").asc().build(); // Act String sql = DynamicSqlFactory.newQuery().select().count().from(internalSql).as("subQuery").build(); // Assert assertThatSelect(sql); assertThatFrom(sql); assertThatJoin(sql); assertThatWhere(sql); assertThatAnd(sql); assertThatGroupBy(sql); assertThatHaving(sql); assertThatOrderBy(sql); assertThatAll(sql); }
From source file:com.orange.clara.cloud.servicedbdumper.task.ScheduledDeleteAllDumpsTask.java
@Scheduled(fixedDelay = 7000) public void deleteAllDumps() throws JobCreationException, AsyncTaskException { List<Job> jobs = jobRepo.findByJobTypeAndJobEvent(JobType.DELETE_DUMPS, JobEvent.START); logger.debug("Running: delete all dump scheduled task ..."); LocalDateTime whenRemoveDateTime; for (Job job : jobs) { whenRemoveDateTime = LocalDateTime.from(job.getUpdatedAt().toInstant().atZone(ZoneId.systemDefault())) .plusDays(this.dumpDeleteExpirationDays); if (LocalDateTime.from(Calendar.getInstance().toInstant().atZone(ZoneId.systemDefault())) .isBefore(whenRemoveDateTime)) { continue; }/*from ww w.ja v a 2 s . c o m*/ job.setJobEvent(JobEvent.RUNNING); jobRepo.save(job); this.deleteDumpTask.runTask(job.getId()); } logger.debug("Finished: delete all dump scheduled task."); }
From source file:com.yqboots.fss.core.support.FileItemConsumer.java
/** * {@inheritDoc}// w w w .j a v a 2s . c om */ @Override public void accept(final Path path) { final File file = path.toFile(); final FileItem item = new FileItem(); item.setName(file.getName()); String relativePath = StringUtils.substringAfter(file.getPath(), root.toString()); item.setPath(relativePath.replace("\\", "/")); item.setLength(file.length()); item.setLastModifiedDate( LocalDateTime.ofInstant(new Date(file.lastModified()).toInstant(), ZoneId.systemDefault())); items.add(item); }
From source file:de.adorsys.multibanking.hbci.model.HbciMapping.java
private static Balance createBalance(Saldo saldo) { return Balance.builder().date(saldo.timestamp.toInstant().atZone(ZoneId.systemDefault()).toLocalDate()) .currency(saldo.value.getCurr()).amount(saldo.value.getBigDecimalValue().setScale(2)).build(); }
From source file:org.openhab.binding.plugwise.internal.PlugwiseUtils.java
public static DateTimeType newDateTimeType(LocalDateTime localDateTime) { return new DateTimeType(localDateTime.atZone(ZoneId.systemDefault())); }
From source file:example.springdata.cassandra.java8.Jsr310IntegrationTests.java
@Test public void findOneByConvertedTypes() { Order order = new Order("42", LocalDate.of(2010, 1, 2), ZoneId.systemDefault()); repository.save(order);/*from w ww. j a v a2s .c om*/ com.datastax.driver.core.LocalDate date = com.datastax.driver.core.LocalDate.fromYearMonthDay(2010, 1, 2); String zoneId = order.getZoneId().getId(); assertThat(repository.findOrderByDate(date, zoneId), is(equalTo(order))); }