List of usage examples for org.joda.time DateTime toLocalDateTime
public LocalDateTime toLocalDateTime()
LocalDateTime
with the same datetime and chronology. From source file:easycare.alc.web.patient.HstPrescriptionView.java
private void setSignatureDetails(TimeZoneHelper timeZoneHelper) { setCountryCode(hstPrescription.getState().getCountry().getCountryCode()); setStateCode(hstPrescription.getState().getStateCode()); DateTime dateTimeAndZone = timeZoneHelper .convertHardwareLocalDateTimeToSystemTZDateTime(hstPrescription.getSignedAt()); setSignedAt(dateTimeAndZone.toLocalDateTime()); setTimezone(dateTimeAndZone.getZone().getShortName(0)); }
From source file:easycare.alc.web.patient.SignatureView.java
protected SignatureView(HstSignature hstSignature, TimeZoneHelper timeZoneHelper) { if (hstSignature.getTitle() != null) { this.title = hstSignature.getTitle().toString(); }//from w w w . jav a 2 s . c om this.firstName = hstSignature.getFirstName(); this.lastName = hstSignature.getLastName(); this.userName = hstSignature.getUsername(); this.orgName = hstSignature.getOrgName(); this.licenseNumber = hstSignature.getLicenseNumber(); this.stateCode = hstSignature.getState().getStateCode(); this.countryCode = hstSignature.getState().getCountry().getCountryCode(); this.addressLine1 = hstSignature.getAddressLine1(); this.addressLine2 = hstSignature.getAddressLine2(); this.citySuburb = hstSignature.getCitySuburb(); this.postcode = hstSignature.getPostcode(); DateTime dateTimeAndZone = timeZoneHelper .convertHardwareLocalDateTimeToSystemTZDateTime(hstSignature.getSignedAt()); this.signedAt = dateTimeAndZone.toLocalDateTime(); this.timezone = dateTimeAndZone.getZone().getShortName(0); this.detailedReportFormat = hstSignature.getHstReportType().isDetailed(); }
From source file:eu.europa.ec.fisheries.uvms.movement.util.DateUtil.java
License:Open Source License
public static Date parseToUTCDate(String dateTimeInUTC) { for (DateFormats format : DateFormats.values()) { DateTimeFormatter formatter = DateTimeFormat.forPattern(format.getFormat()); DateTime dateTime = formatter.withZoneUTC().parseDateTime(dateTimeInUTC); if (dateTime != null) { return dateTime.toLocalDateTime().toDate(); }//from w w w . ja v a 2 s . c o m } LOG.error("Could not parse dateTimeInUTC: " + dateTimeInUTC + " with pattern any defined pattern."); return null; }
From source file:eu.europa.ec.fisheries.uvms.movement.util.DateUtil.java
License:Open Source License
public static Date parseToUTCDate_a_more_stable_if_you_want_to_work_like_this(String dateTimeInUTC) { try {/*w ww. jav a2s. c om*/ for (DateFormats format : DateFormats.values()) { try { DateTimeFormatter formatter = DateTimeFormat.forPattern(format.getFormat()); DateTime dateTime = formatter.withZoneUTC().parseDateTime(dateTimeInUTC); if (dateTime != null) { return dateTime.toLocalDateTime().toDate(); } } catch (RuntimeException e) { LOG.error("Could not parse dateTimeInUTC: " + dateTimeInUTC + " with pattern any defined pattern."); continue; } } } catch (RuntimeException e) { LOG.error("Could not parse dateTimeInUTC: " + dateTimeInUTC + " with pattern any defined pattern."); return null; } LOG.error("Could not parse dateTimeInUTC: " + dateTimeInUTC + " with pattern any defined pattern."); return null; }
From source file:eu.europa.ec.fisheries.uvms.plugins.naf.util.DateUtil.java
License:Open Source License
private static Date parseToUTC(String format, String dateString) { DateTimeFormatter formatter = DateTimeFormat.forPattern(format); DateTime dateTime = formatter.withZoneUTC().parseDateTime(dateString); LOG.info("JodaTime: {}", dateTime); return dateTime.toLocalDateTime().toDate(); }
From source file:io.spikex.filter.internal.Rule.java
License:Apache License
private int compareToDateTime(final DateTime d1, final Object obj) { DateTimeFormatter fmt = (DateTimeFormatter) m_fmt; String dateStr = String.valueOf(obj); DateTime d2 = fmt.parseDateTime(dateStr); // https://github.com/JodaOrg/joda-time/issues/73 return d1.toLocalDateTime().compareTo(d2.toLocalDateTime()); }
From source file:org.bryantd.lightscameraaction.LightsCameraActionWorker.java
@Override protected Integer doInBackground() throws Exception { final DateTimeFormatter dtf = DateTimeFormat.forPattern("yyyy-MM-dd '-' HH:mm:ss.SSSS"); String fileName;/*from www. j a v a 2s . c o m*/ while (imageJobScheduleIterator_.hasNext()) { LightsCameraActionWorker.failIfInterrupted(); DateTime nextScheduledEvent = (DateTime) imageJobScheduleIterator_.next(); process(Arrays.asList(Utilities .timeStamp("Next snapshot scheduled for " + dtf.print(nextScheduledEvent)).toString())); if (nextScheduledEvent.isAfterNow()) { waitUntil(nextScheduledEvent); process(Arrays.asList(Utilities.timeStamp("Begining scheduled image acquisition.").toString())); Boolean okToExecuteJob = true; if (requireRunningSchedule_) { process(Arrays.asList(Utilities.timeStamp("Checking lights for running schedule:").toString())); try { okToExecuteJob = lights_.issueCommands(Arrays.asList(LightsTask.GETSCHEDULERUNNING), null, null); } catch (InterruptedException e) { throw (e); } catch (Exception e) { okToExecuteJob = false; process(Arrays.asList(Utilities.timeStamp("Error: " + e.getMessage()).toString())); process(Arrays.asList(Utilities.timeStamp("Error type: " + e.getCause()).toString())); process(Arrays.asList( Utilities.timeStamp("Could not issue lights command. Skipping this scheduled job.") .toString())); } if (okToExecuteJob) { process(Arrays.asList( Utilities.timeStamp("Schedule is running on lights, proceeding.").toString())); } else { process(Arrays.asList(Utilities .timeStamp("Schedule is not running on lights! Skipping job.").toString())); okToExecuteJob = false; } } if (okToExecuteJob) { boolean success = true; fileName = nextScheduledEvent.toLocalDateTime().toString().replace(':', '-'); process(Arrays.asList(Utilities.timeStamp("Executing image acquisition routine.").toString())); lights_.issueCommands(Arrays.asList(LightsTask.SCHEDULESTOP, LightsTask.SETWL), null, setWLCommand_); DateTime takeImageEvent = DateTime.now().plusMillis(lightsToImageDelayMS_); waitUntil(takeImageEvent); try { success = camera_.snapImage(fileName); failIfInterrupted(); } catch (Exception e) { process(Arrays .asList(Utilities.timeStamp("Error snapping image: " + e.getMessage()).toString())); process(Arrays.asList( Utilities.timeStamp("Could not issue camera command. Skipping this scheduled job.") .toString())); } if (success) { process(Arrays.asList(Utilities.timeStamp("Successfully acquired image.").toString())); } else { process(Arrays .asList(Utilities.timeStamp("Something went wrong with this job.").toString())); } lights_.issueCommands(Arrays.asList(LightsTask.SCHEDULESTART), null, null); } } else { process(Arrays.asList(Utilities.timeStamp("Scheduled job is in the past. Skipping.").toString())); System.out.println("event skipped"); } } process(Arrays.asList(Utilities.timeStamp("Done processing full schedule.").toString())); return 0; }
From source file:org.efaps.esjp.bpm.listener.PotentialOwnerListener_Base.java
License:Apache License
@Override public Return execute(final Parameter _parameter) throws EFapsException { final Return ret = new Return(); final List<?> owners = (List<?>) _parameter.get(ParameterValues.BPM_VALUES); if (!owners.isEmpty()) { final List<String> uuids = new ArrayList<String>(); final List<AbstractUserObject> newOwners = new ArrayList<AbstractUserObject>(); for (final Object owner : owners) { newOwners.add((AbstractUserObject) owner); uuids.add(((AbstractUserObject) owner).getUUID().toString()); }/*from w w w .j ava2 s . c o m*/ final DateTime date = new DateMidnight().toDateTime(); final QueryBuilder queryBldr = new QueryBuilder(CIBPM.DelegateAutomaticAbstract); queryBldr.addWhereAttrEqValue(CIBPM.DelegateAutomaticAbstract.FromUserUUID, uuids.toArray()); queryBldr.addWhereAttrGreaterValue(CIBPM.DelegateAutomaticAbstract.ValidFrom, date.minusDays(1).minusSeconds(1)); queryBldr.addWhereAttrLessValue(CIBPM.DelegateAutomaticAbstract.ValidUntil, date.plusDays(1).plusSeconds(1)); final CachedMultiPrintQuery multi = queryBldr.getCachedPrint(BPM.CACHEKEY4DELEGATE).setLifespan(8) .setLifespanUnit(TimeUnit.HOURS); multi.addAttribute(CIBPM.DelegateAutomaticAbstract.ToUserUUID, CIBPM.DelegateAutomaticAbstract.ValidFrom, CIBPM.DelegateAutomaticAbstract.ValidUntil); multi.executeWithoutAccessCheck(); while (multi.next()) { final DateTime validFrom = multi.<DateTime>getAttribute(CIBPM.DelegateAutomaticAbstract.ValidFrom); final DateTime validUntil = multi .<DateTime>getAttribute(CIBPM.DelegateAutomaticAbstract.ValidUntil); if (validFrom.toLocalDateTime().isBefore(new LocalDateTime()) && validUntil.toLocalDateTime().isAfter(new LocalDateTime())) { final String tuUserUUID = multi .<String>getAttribute(CIBPM.DelegateAutomaticAbstract.ToUserUUID); newOwners.add(AbstractUserObject.getUserObject(UUID.fromString(tuUserUUID))); } } ret.put(ReturnValues.VALUES, newOwners); } return ret; }
From source file:org.gdg.frisbee.android.utils.Utils.java
License:Apache License
public static String toHumanTimePeriod(Context ctx, DateTime start, DateTime end) { String result;// ww w .ja va 2 s .co m Resources res = ctx.getResources(); Period p = new Period(start, end); if (p.getYears() == 0 && p.getMonths() == 0 && p.getWeeks() == 0 && p.getDays() == 0 && p.getHours() == 0 && p.getMinutes() == 0) { result = res.getQuantityString(R.plurals.seconds_ago, p.getSeconds(), p.getSeconds()); } else if (p.getYears() == 0 && p.getMonths() == 0 && p.getWeeks() == 0 && p.getDays() == 0 && p.getHours() == 0) { result = res.getQuantityString(R.plurals.minutes_ago, p.getMinutes(), p.getMinutes()); } else if (p.getYears() == 0 && p.getMonths() == 0 && p.getWeeks() == 0 && p.getDays() == 0) { result = res.getQuantityString(R.plurals.hours_ago, p.getHours(), p.getHours()); } else if (p.getYears() == 0 && p.getMonths() == 0 && p.getWeeks() == 0) { result = res.getQuantityString(R.plurals.days_ago, p.getDays(), p.getDays()); } else { result = start.toLocalDateTime() .toString(DateTimeFormat.patternForStyle("M-", res.getConfiguration().locale)); } return result; }
From source file:org.gradle.performance.fixture.GCEventParser.java
License:Apache License
GCEvent parseLine(String line) { if (line.trim().isEmpty()) { return GCEvent.IGNORED; }//from w ww . j av a 2 s .com Matcher matcher = pattern.matcher(line); if (!matcher.lookingAt()) { if (ignorePattern.matcher(line).matches()) { //I see this kind of events on windows. Let's see if this approach helps resolving them. return GCEvent.IGNORED; } else { notParsed.add(line); return GCEvent.IGNORED; } } try { DateTime timestamp = DateTime.parse(matcher.group(1)); // Some JVMs generate an incorrect timezone offset in the timestamps. Discard timezone and use the local timezone instead timestamp = timestamp.toLocalDateTime().toDateTime(DateTimeZone.getDefault()); long start = Long.parseLong(matcher.group(2)); long end = Long.parseLong(matcher.group(3)); long committed = Long.parseLong(matcher.group(4)); return new GCEvent(start, end, committed, timestamp); } catch (Exception ex) { notParsed.add(line); return GCEvent.IGNORED; } }