List of usage examples for org.joda.time LocalDateTime toDateTime
public DateTime toDateTime()
From source file:com.axelor.apps.organisation.service.LeaveRequestService.java
License:Open Source License
public Duration computeDuration(LocalDateTime startDateTime, LocalDateTime endDateTime) { return new Interval(startDateTime.toDateTime(), endDateTime.toDateTime()).toDuration(); }
From source file:com.axelor.apps.tool.date.DurationTool.java
License:Open Source License
public static Duration computeDuration(LocalDateTime startDateTime, LocalDateTime endDateTime) { return new Interval(startDateTime.toDateTime(), endDateTime.toDateTime()).toDuration(); }
From source file:com.ephemeraldreams.gallyshuttle.ui.MainFragment.java
License:Apache License
/** * Calculate time difference in milliseconds between now and next available shuttle arrival time. * * @param stationId Station id to get times from. * @return Duration between now and next arrival time in milliseconds. *//* w w w. j av a2s. c om*/ private long calculateTimeFromNowToNextArrivalAtStation(int stationId) { List<String> times = schedule.getTimes(stationId); LocalDateTime now = LocalDateTime.now(); arrivalTime = null; LocalDateTime stationTime; for (String time : times) { stationTime = DateUtils.parseToLocalDateTime(time); Timber.d(stationTime.toString()); //Workaround midnight exception case where station time was converted to midnight of current day instead of next day. if (stationTime.getHourOfDay() == 0 && now.getHourOfDay() != 0) { stationTime = stationTime.plusDays(1); } if (now.isBefore(stationTime)) { arrivalTime = stationTime; break; } } if (arrivalTime == null) { arrivalTimeTextView.setText(getString(R.string.arrival_not_available_message)); return -1; } else { arrivalTimeTextView.setText(String.format(getString(R.string.until_arrival_time_message), DateUtils.formatTime(arrivalTime))); Duration duration = new Duration(now.toDateTime(), arrivalTime.toDateTime()); long milliseconds = duration.getMillis(); Timber.d("Now: " + DateUtils.formatTime(now)); Timber.d("Arrival: " + DateUtils.formatTime(arrivalTime)); Timber.d("Time difference between now and arrival: " + DateUtils.convertMillisecondsToTime(milliseconds)); return milliseconds; } }
From source file:com.fujitsu.dc.core.model.Box.java
License:Apache License
/** * Constructor.//from w ww . j a v a 2 s. c om * @param cell cell * @param entity OEntity */ public Box(final Cell cell, final OEntity entity) { this.cell = cell; if (entity == null) { // ?? this.name = Box.DEFAULT_BOX_NAME; // ?URL??URL?? this.schema = cell.getUrl(); // ?ID??ID??? this.id = cell.getId(); return; } this.name = (String) entity.getProperty("Name").getValue(); this.schema = (String) entity.getProperty(P_SCHEMA.getName()).getValue(); if (entity instanceof OEntityWrapper) { OEntityWrapper oew = (OEntityWrapper) entity; this.id = oew.getUuid(); } LocalDateTime dateTime = (LocalDateTime) entity.getProperty(Common.P_PUBLISHED.getName()).getValue(); this.published = dateTime.toDateTime().getMillis(); }
From source file:com.fujitsu.dc.core.model.impl.es.doc.OEntityDocHandler.java
License:Apache License
/** * OEntityWrapper? ID???DocHandler???.// w ww .j av a 2s . c o m * @param typeName ES?type?? * @param oEntityWrapper OEntityWrapper * @param metadata */ @SuppressWarnings("unchecked") protected void initInstance(String typeName, OEntityWrapper oEntityWrapper, EdmDataServices metadata) { this.type = typeName; // ??uuidES ID???? this.id = oEntityWrapper.getUuid(); // OEntity Wrapper????? Version, hiddenField?? this.hiddenFields = oEntityWrapper.getMetadata(); // Cell????UnitUser??? resolveUnitUserName(); String etag = oEntityWrapper.getEtag(); if (etag != null && etag.length() > 1) { this.version = Long.valueOf(etag.substring(0, etag.indexOf("-"))); } // ? EdmEntitySet entitySet = oEntityWrapper.getEntitySet(); EdmEntityType eType = entitySet.getType(); // ???NavProp? List<EdmNavigationProperty> navProps = eType.getDeclaredNavigationProperties().toList(); for (EdmNavigationProperty np : navProps) { // NavProp??????? EdmMultiplicity mf = np.getFromRole().getMultiplicity(); EdmMultiplicity mt = np.getToRole().getMultiplicity(); // Association?Multiplicity????????MANY??ONE?????? // NavigationProperty?URL??l???? if (EdmMultiplicity.ONE.equals(mt) && EdmMultiplicity.MANY.equals(mf)) { // TODO log.debug("many to one"); } } // ????????????? for (OProperty<?> prop : oEntityWrapper.getProperties()) { // ???????Dynamic Property?Declared Property??? String propName = prop.getName(); EdmProperty edmProperty = eType.findProperty(propName); // ?Property?DynamicProperty???? if (edmProperty != null) { // ?? // TODO ??????????? ????????????? // ???????????? // ?????. Object value = prop.getValue(); if ("__published".equals(propName)) { OProperty<LocalDateTime> propD = (OProperty<LocalDateTime>) prop; LocalDateTime ldt = propD.getValue(); this.published = ldt.toDateTime().getMillis(); } else if ("__updated".equals(propName)) { OProperty<LocalDateTime> propD = (OProperty<LocalDateTime>) prop; LocalDateTime ldt = propD.getValue(); this.updated = ldt.toDateTime().getMillis(); } else { CollectionKind ck = edmProperty.getCollectionKind(); if (edmProperty.getType().isSimple()) { if (ck.equals(CollectionKind.List)) { // ????? if (value == null || value instanceof OCollection<?>) { this.staticFields.put(prop.getName(), getSimpleList(edmProperty.getType(), (OCollection<OObject>) value)); } else { throw DcCoreException.OData.REQUEST_FIELD_FORMAT_ERROR.params(prop.getName()); } } else { value = getSimpleValue(prop, edmProperty.getType()); // Property?Simple????????????? this.staticFields.put(prop.getName(), value); } } else { String complexTypeName = edmProperty.getType().getFullyQualifiedTypeName(); if (ck.equals(CollectionKind.List)) { // CollectionKind?List??????? this.staticFields.put(prop.getName(), getComplexList( (OCollection<OComplexObject>) prop.getValue(), metadata, complexTypeName)); } else { // Property?Complex?????ComplexType???? this.staticFields.put(prop.getName(), getComplexType(prop, metadata, complexTypeName)); } } } } else { // Dynamic??String,Integer,Float,Boolean?? Object propValue = prop.getValue(); if ("Edm.DateTime".equals(prop.getType().getFullyQualifiedTypeName())) { OProperty<LocalDateTime> propD = (OProperty<LocalDateTime>) prop; LocalDateTime ldt = propD.getValue(); if (ldt != null) { propValue = "\\/Date(" + ldt.toDateTime().toDate().getTime() + ")\\/"; } } this.dynamicFields.put(prop.getName(), propValue); } } }
From source file:com.fujitsu.dc.core.model.impl.es.doc.OEntityDocHandler.java
License:Apache License
/** * ???????????.//from ww w . j av a2 s . c o m * @param prop * @param edmType ? * @return ?????? */ @SuppressWarnings("unchecked") protected Object getSimpleValue(OProperty<?> prop, EdmType edmType) { if (edmType.equals(EdmSimpleType.DATETIME)) { OProperty<LocalDateTime> propD = (OProperty<LocalDateTime>) prop; LocalDateTime ldt = propD.getValue(); if (ldt != null) { return ldt.toDateTime().getMillis(); } } return prop.getValue(); }
From source file:com.fujitsu.dc.core.model.impl.es.doc.OEntityDocHandler.java
License:Apache License
/** * ??????.//from w w w .j a v a 2s . c o m * @param edmType EdmSimpleType * @param propValue ?? * @return ?? */ @SuppressWarnings("unchecked") protected Object convertSimpleListValue(final EdmType edmType, Object propValue) { if (edmType.equals(EdmSimpleType.DATETIME)) { OProperty<LocalDateTime> propD = (OProperty<LocalDateTime>) propValue; if (propD != null) { LocalDateTime ldt = propD.getValue(); if (ldt != null) { return ldt.toDateTime().getMillis(); } } } return propValue; }
From source file:com.fujitsu.dc.core.model.impl.es.doc.UserDataDocHandler.java
License:Apache License
/** * ???????????.<br/>// w ww.ja v a 2s . c om * ???Boolean????. * @param prop * @param edmType ? * @return ?????? */ @Override @SuppressWarnings("unchecked") protected Object getSimpleValue(OProperty<?> prop, EdmType edmType) { if (edmType.equals(EdmSimpleType.DATETIME)) { OProperty<LocalDateTime> propD = (OProperty<LocalDateTime>) prop; LocalDateTime ldt = propD.getValue(); if (ldt != null) { return ldt.toDateTime().getMillis(); } } // Boolean/Double???? if (prop.getValue() != null && (edmType.equals(EdmSimpleType.BOOLEAN) || edmType.equals(EdmSimpleType.DOUBLE))) { return String.valueOf(prop.getValue()); } return prop.getValue(); }
From source file:com.gs.fw.common.mithra.test.cacheloader.PYETopLevelLoaderFactory.java
License:Apache License
protected Timestamp shiftBusinessDate(Timestamp businessDate) { LocalDate localDate = new LocalDate(businessDate); int year = localDate.getYear(); LocalDateTime pye = new LocalDateTime(year - 1, 12, 31, 23, 59, 0, 0); int dayOfWeek = pye.dayOfWeek().get(); if (dayOfWeek > 5) { pye = pye.minusDays(dayOfWeek - 5); }//from w w w . ja v a 2s. c o m return new Timestamp(pye.toDateTime().getMillis()); }
From source file:com.hamdikavak.humanmobility.modeling.helpers.LocationTraceHelper.java
License:Open Source License
public List<LocationTrace> selectBetweenDates(List<LocationTrace> traces, LocalDateTime startDateInclusive, LocalDateTime endDateExclusive) { List<LocationTrace> newTraces = new ArrayList<LocationTrace>(); for (LocationTrace aTrace : traces) { if (aTrace.getLocalTime().toDateTime().getMillis() >= startDateInclusive.toDateTime().getMillis() && aTrace.getLocalTime().toDateTime().getMillis() < endDateExclusive.toDateTime().getMillis()) { newTraces.add(new LocationTrace(aTrace)); }/* w ww . ja v a 2 s.c o m*/ } return newTraces; }