/** Get the origin Date. * @return Date or null if not a time unit. */ public Date getDateOrigin() { if (!(uu instanceof TimeScaleUnit)) return null; TimeScaleUnit tu = (TimeScaleUnit) uu; return tu.getOrigin(); }
/** * Get the origin Date. * * @return Date or null if not a time unit. */ public Date getDateOrigin() { if (!(uu instanceof TimeScaleUnit)) return null; TimeScaleUnit tu = (TimeScaleUnit) uu; return tu.getOrigin(); }
/** Get the origin Date. * @return Date or null if not a time unit. */ public Date getDateOrigin() { if (!(uu instanceof TimeScaleUnit)) return null; TimeScaleUnit tu = (TimeScaleUnit) uu; return tu.getOrigin(); }
/** * Returns the hash code of this instance. * * @return The hash code of this instance. */ @Override public int hashCode() { return getUnit().hashCode() ^ getOrigin().hashCode(); }
/** * Returns the hash code of this instance. * * @return The hash code of this instance. */ @Override public int hashCode() { return getUnit().hashCode() ^ getOrigin().hashCode(); }
private StringBuffer format(TimeScaleUnit unit, StringBuffer buf, boolean normalize) throws UnitClassException { return format(unit.getUnit(), buf, normalize). append(dateFormat.format(unit.getOrigin())); }
private StringBuffer format(TimeScaleUnit unit, StringBuffer buf, boolean normalize) throws UnitClassException { return format(unit.getUnit(), buf, normalize). append(dateFormat.format(unit.getOrigin())); }
/** * Returns the canonical string representation of the unit. * * @return The canonical string representation. */ public String getCanonicalString() { /* change this, not thread-safe; require dependency of joda-time (!) dateFormat = (SimpleDateFormat) DateFormat.getDateInstance(DateFormat.SHORT, Locale.US); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); dateFormat.applyPattern(" 'since' yyyy-MM-dd HH:mm:ss.SSS 'UTC'"); */ return getUnit().toString() + " since " + df_units.print(getOrigin().getTime()); }
/** * Returns the canonical string representation of the unit. * * @return The canonical string representation. */ public String getCanonicalString() { /* change this, not thread-safe; require dependency of joda-time (!) dateFormat = (SimpleDateFormat) DateFormat.getDateInstance(DateFormat.SHORT, Locale.US); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); dateFormat.applyPattern(" 'since' yyyy-MM-dd HH:mm:ss.SSS 'UTC'"); */ return getUnit().toString() + " since " + df_units.print(getOrigin().getTime()); }
protected MyConverter(final TimeScaleUnit fromUnit, final Unit toUnit) throws ConversionException { super(fromUnit, toUnit); converter = fromUnit.getUnit().getConverterTo( ((TimeScaleUnit) toUnit).getUnit()); offset = SI.SECOND.convertTo( (fromUnit.getOrigin().getTime() - ((TimeScaleUnit) toUnit) .getOrigin().getTime()) / 1000.0, ((TimeScaleUnit) toUnit).getUnit()); }
protected MyConverter(final TimeScaleUnit fromUnit, final Unit toUnit) throws ConversionException { super(fromUnit, toUnit); converter = fromUnit.getUnit().getConverterTo( ((TimeScaleUnit) toUnit).getUnit()); offset = SI.SECOND.convertTo( (fromUnit.getOrigin().getTime() - ((TimeScaleUnit) toUnit) .getOrigin().getTime()) / 1000.0, ((TimeScaleUnit) toUnit).getUnit()); }
/** * Clones this unit, changing the identifier. * * @param id The new identifier. * @return This unit with the new identifier. */ public Unit clone(final UnitName id) { Unit clone; try { clone = new TimeScaleUnit(getUnit(), getOrigin(), id); } catch (final UnitException e) { clone = null; // can't happen } return clone; }
/** * Clones this unit, changing the identifier. * * @param id The new identifier. * @return This unit with the new identifier. */ public Unit clone(final UnitName id) { Unit clone; try { clone = new TimeScaleUnit(getUnit(), getOrigin(), id); } catch (final UnitException e) { clone = null; // can't happen } return clone; }
private Date getBase(String s) throws Exception { Unit u = format.parse(s); assert u instanceof TimeScaleUnit : s; TimeScaleUnit tu = (TimeScaleUnit) u; return tu.getOrigin(); }