List of usage examples for org.joda.time Duration toPeriodFrom
public Period toPeriodFrom(ReadableInstant startInstant)
From source file:org.openehr.rm.datatypes.quantity.datetime.DvDuration.java
License:LGPL
/** * Create a Duration from two instances of DvWorldTime * * @param start//w ww . j ava2s. co m * @param end */ public static DvDuration getDifference(DvTemporal start, DvTemporal end) { Duration d = new Duration(start.getDateTime(), end.getDateTime()); DvDateTime dt = (DvDateTime) end; return new DvDuration(null, null, null, 0.0, false, null, d.toPeriodFrom(start.getDateTime())); }
From source file:org.openehr.rm.datatypes.quantity.datetime.DvDuration.java
License:LGPL
/** * Sum of this quantity and another whose formal type must be the difference * type of this quantity.//from w ww. j a v a2 s .co m * * @param q * @return production of addition * @throws ClassCastException */ @Override public DvQuantified<DvDuration> add(DvQuantified q) { final DvDuration d = (DvDuration) q; DateTime dt = new DateTime(0); Duration duration = period.toDurationFrom(dt); Duration result = duration.plus(d.period.toDurationFrom(dt)); Period p = result.toPeriodFrom(dt); return new DvDuration(d.getOtherReferenceRanges(), d.getNormalRange(), d.getNormalStatus(), d.getAccuracy(), d.isAccuracyPercent(), d.getMagnitudeStatus(), p); }
From source file:org.openehr.rm.datatypes.quantity.datetime.DvDuration.java
License:LGPL
/** * Difference of this quantity and another whose formal type must be the * difference type of this quantity type. * /*from w w w . ja v a 2 s .com*/ * @param q * @return product of substraction * @throws ClassCastException */ @Override public DvQuantified<DvDuration> subtract(DvQuantified q) { final DvDuration d = (DvDuration) q; DateTime dt = new DateTime(0); Duration duration = period.toDurationFrom(dt); Duration result = duration.minus(d.period.toDurationFrom(dt)); Period p = result.toPeriodFrom(dt); return new DvDuration(d.getOtherReferenceRanges(), d.getNormalRange(), d.getNormalStatus(), d.getAccuracy(), d.isAccuracyPercent(), d.getMagnitudeStatus(), p); }