List of usage examples for java.time LocalDateTime of
public static LocalDateTime of(LocalDate date, LocalTime time)
From source file:ch.digitalfondue.npjt.query.DateTimeQueriesTest.java
private void check(DateQueries dq, String key, LocalDate now) { Assert.assertEquals(now, dq.findByKey(key).valueLocalDate); Assert.assertEquals(LocalDateTime.of(now, LocalTime.MIDNIGHT), dq.findByKey(key).valueLocalDateTime); }
From source file:me.rkfg.xmpp.bot.plugins.FaggotOfTheDayPlugin.java
private Date getFirstTime() { final LocalTime midnight = LocalTime.MIDNIGHT; final LocalDate today = LocalDate.now(); final LocalDateTime todayMidnight = LocalDateTime.of(today, midnight); return Date.from(todayMidnight.atZone(ZoneId.systemDefault()).toInstant()); }
From source file:com.qwazr.externalizor.SimpleTime.java
public SimpleTime() { calNullValue = null;//from w w w .j a va 2s .co m calValue = Calendar.getInstance(); calValue.setTimeInMillis(RandomUtils.nextLong()); calArray = new Calendar[] { calNullValue, calValue }; calList = new ArrayList(Arrays.asList(calValue, calNullValue)); dateNullValue = null; dateValue = new Date(RandomUtils.nextLong()); dateArray = new Date[] { dateNullValue, dateValue }; dateList = new ArrayList(Arrays.asList(dateValue, dateNullValue)); durationNullValue = null; durationValue = Duration.ofSeconds(RandomUtils.nextLong()); durationArray = new Duration[] { durationNullValue, durationValue }; durationList = new ArrayList(Arrays.asList(durationValue, durationNullValue)); instantNullValue = null; instantValue = Instant.ofEpochSecond(RandomUtils.nextLong(0, Instant.MAX.getEpochSecond())); instantArray = new Instant[] { instantNullValue, instantValue }; instantList = new ArrayList(Arrays.asList(instantValue, instantNullValue)); localTimeNullValue = null; localTimeValue = LocalTime.of(RandomUtils.nextInt(0, 24), RandomUtils.nextInt(0, 60), RandomUtils.nextInt(0, 60)); localTimeArray = new LocalTime[] { localTimeNullValue, localTimeValue }; localTimeList = new ArrayList(Arrays.asList(localTimeValue, localTimeNullValue)); localDateNullValue = null; localDateValue = LocalDate.of(RandomUtils.nextInt(2000, 3000), RandomUtils.nextInt(1, 13), RandomUtils.nextInt(1, 29)); localDateArray = new LocalDate[] { localDateNullValue, localDateValue }; localDateList = new ArrayList(Arrays.asList(localDateValue, localDateNullValue)); localDateTimeNullValue = null; localDateTimeValue = LocalDateTime.of( LocalDate.of(RandomUtils.nextInt(2000, 3000), RandomUtils.nextInt(1, 13), RandomUtils.nextInt(1, 29)), LocalTime.of(RandomUtils.nextInt(0, 24), RandomUtils.nextInt(0, 60), RandomUtils.nextInt(0, 60))); localDateTimeArray = new LocalDateTime[] { localDateTimeNullValue, localDateTimeValue }; localDateTimeList = new ArrayList(Arrays.asList(localDateTimeValue, localDateTimeNullValue)); monthDayNullValue = null; monthDayValue = MonthDay.of(RandomUtils.nextInt(1, 13), RandomUtils.nextInt(1, 29)); monthDayArray = new MonthDay[] { monthDayNullValue, monthDayValue }; monthDayList = new ArrayList(Arrays.asList(monthDayValue, monthDayNullValue)); periodNullValue = null; periodValue = Period.of(RandomUtils.nextInt(0, Year.MAX_VALUE), RandomUtils.nextInt(1, 13), RandomUtils.nextInt(1, 29)); periodArray = new Period[] { periodNullValue, periodValue }; periodList = new ArrayList(Arrays.asList(periodValue, periodNullValue)); yearNullValue = null; yearValue = Year.of(RandomUtils.nextInt(0, Year.MAX_VALUE)); yearArray = new Year[] { yearNullValue, yearValue }; yearList = new ArrayList(Arrays.asList(yearValue, yearNullValue)); }
From source file:net.bis5.slack.command.gcal.SlashCommandApi.java
private EventDateTime toDateTime(LocalDate date, LocalTime time) { if (time != null) { DateTime dateTime = new DateTime( Date.from(LocalDateTime.of(date, time).toInstant(ZoneOffset.ofHours(+9)))); return new EventDateTime().setDateTime(dateTime); } else {/*from w w w. ja v a2 s. co m*/ DateTime dateTime = new DateTime(true, Date.from(date.atStartOfDay().toInstant(ZoneOffset.UTC)).getTime(), 9); return new EventDateTime().setDate(dateTime); } }
From source file:com.romeikat.datamessie.core.base.dao.impl.DocumentDao.java
public List<Document> getForSourceAndDownloaded(final SharedSessionContract ssc, final long sourceId, final LocalDate downloaded) { final LocalDateTime minDownloaded = LocalDateTime.of(downloaded, LocalTime.MIDNIGHT); final LocalDateTime maxDownloaded = LocalDateTime.of(downloaded.plusDays(1), LocalTime.MIDNIGHT); // Query: Document final EntityWithIdQuery<Document> documentQuery = new EntityWithIdQuery<>(Document.class); documentQuery.addRestriction(Restrictions.eq("sourceId", sourceId)); documentQuery.addRestriction(Restrictions.ge("downloaded", minDownloaded)); documentQuery.addRestriction(Restrictions.lt("downloaded", maxDownloaded)); // Done/* www . jav a2s . co m*/ final List<Document> entities = documentQuery.listObjects(ssc); return entities; }
From source file:gov.ca.cwds.cals.service.ComplaintsService.java
@UnitOfWork(CMS) protected List<ComplaintDto> getCountyLicenseCaseComplaints(String facilityNumber) { Map<LocalDate, List<CountyLicenseCaseComplaintInfo>> complaintsAggregation = countyLicenseCaseComplaintInfoDao .loadCountyLicenseCaseComplaintsByLicenseNumber(facilityNumber).stream() .collect(Collectors.groupingBy(CountyLicenseCaseComplaintInfo::getComplaintDate)); List<ComplaintDto> complaints = new ArrayList<>(complaintsAggregation.size()); for (Map.Entry<LocalDate, List<CountyLicenseCaseComplaintInfo>> entry : complaintsAggregation.entrySet()) { ComplaintDto complaintDto = new ComplaintDto(); complaintDto.setComplaintDate(LocalDateTime.of(entry.getKey(), LocalTime.NOON)); List<AllegationDto> allegations = entry.getValue().stream() .map(CountyLicenseCaseComplaintInfo::toAllegationDto).collect(Collectors.toList()); complaintDto.setAllegations(allegations); complaints.add(complaintDto);/*from w w w . ja v a 2s. co m*/ } return complaints; }
From source file:fr.lepellerin.ecole.service.internal.CantineServiceImpl.java
@Override @Transactional(readOnly = true)//w w w . j a v a 2 s. c om public LocalDateTime getLimiteResaCantine(final LocalDate date) { final LocalTime midnight = LocalTime.MIDNIGHT; final LocalDateTime limiteResa = LocalDateTime.of(date, midnight); final ParametreWeb p = this.paramRepo.findOne(EnumParametreWeb.ID_OFFSET_RESA.getId()); int h = 0; int m = 0; if (p != null) { if (p.getValeurParametre().startsWith("-")) { final String[] hm = p.getValeurParametre().substring(1).split(":"); h = -Integer.valueOf(hm[0]); m = Integer.valueOf(hm[1]); } else { String[] hm; if (p.getValeurParametre().startsWith("+")) { hm = p.getValeurParametre().substring(1).split(":"); } else { hm = p.getValeurParametre().split(":"); } h = Integer.valueOf(hm[0]); m = Integer.valueOf(hm[1]); } } return GeDateUtils.addHeureMinute(limiteResa, h, m); }
From source file:jef.tools.DateUtils.java
/** * Convert LocalTime to jud.//from w ww . ja v a 2 s . c o m * * @param time * LocalTime * @return java.util.Date */ public static Date fromLocalTime(LocalTime time) { return time == null ? null : Date.from(LocalDateTime.of(LocalDate.now(), time).atZone(ZoneId.systemDefault()).toInstant()); }
From source file:jef.tools.DateUtils.java
/** * Converts LocalTime to Timestamp (null safety) * @param localTime LocalTime/*from w w w . j a va2 s . co m*/ * @return Timestamp */ public static Timestamp toSqlTimeStamp(LocalTime localTime) { return localTime == null ? null : java.sql.Timestamp.valueOf(LocalDateTime.of(LocalDate.now(), localTime)); }
From source file:org.jgrades.lic.app.utils.LicenceBuilder.java
public LicenceBuilder withStartOfValid(LocalDate fromDateTime) { if (Optional.ofNullable(fromDateTime).isPresent() && !StringUtils.isEmpty(fromDateTime.toString())) { product.setValidFrom(LocalDateTime.of(fromDateTime, LocalTime.of(0, 0))); }/*from ww w . j av a 2 s .c o m*/ return this; }