/** * {@inheritDoc} * * @see org.modeshape.graph.property.ValueFactory#create(org.modeshape.graph.property.DateTime) */ public String create( DateTime value ) throws ValueFormatException { if (value == null) return null; return value.getString(); // ISO representation }
public int compare( DateTime o1, DateTime o2 ) { if (o1 == o2) return 0; if (o1 == null) return -1; if (o2 == null) return 1; return o1.compareTo(o2); } };
/** * {@inheritDoc} * * @see org.modeshape.graph.property.DateTimeFactory#create(org.modeshape.graph.property.DateTime, long) */ public DateTime create( DateTime original, long offsetInMillis ) { assert original != null; if (offsetInMillis == 0l) return original; long newMillis = original.getMilliseconds() + offsetInMillis; return new JodaDateTime(newMillis, original.getTimeZoneId()); }
/** * {@inheritDoc} * * @see org.modeshape.graph.property.ValueTypeSystem.Factory#create(java.lang.String) */ @Override public DateTime create( String value ) throws ValueFormatException { DateTime result = valueFactory.create(value); // Convert the timestamp to UTC, since that's how everything should be queried ... return result.toUtcTimeZone(); } };
/** * {@inheritDoc} * * @see org.modeshape.graph.property.ValueFactory#create(org.modeshape.graph.property.DateTime) */ public Long create( DateTime value ) throws ValueFormatException { if (value == null) return null; return value.getMilliseconds(); }
/** * {@inheritDoc} */ public int compareTo( org.modeshape.graph.property.DateTime that ) { long diff = this.getMillisecondsInUtc() - that.getMillisecondsInUtc(); return diff == 0 ? 0 : diff > 0 ? 1 : -1; }
public DateTime getExpirationTime() { CachePolicy policy = request.getCachePolicy(); return policy == null ? null : request.getTimeLoaded().plus(policy.getTimeToLive(), TimeUnit.MILLISECONDS); }
/** * Define the right-hand side of a comparison. * * @param literal the literal value that is to be cast * @return the constraint builder; never null */ public CastAs<ConstraintBuilder> cast( DateTime literal ) { return new CastAsRightHandSide(this, literal.toUtcTimeZone()); }
/** * {@inheritDoc} * * @see org.modeshape.graph.property.ValueFactory#create(org.modeshape.graph.property.DateTime) */ public Double create( DateTime value ) throws ValueFormatException { if (value == null) return null; return create(value.getMilliseconds()); }
/** * {@inheritDoc} */ @Override public boolean equals( Object obj ) { if (obj == this) return true; if (obj instanceof org.modeshape.graph.property.DateTime) { org.modeshape.graph.property.DateTime that = (org.modeshape.graph.property.DateTime)obj; return this.getMillisecondsInUtc() == that.getMillisecondsInUtc(); } if (obj instanceof DateTime) { DateTime that = (DateTime)obj; return this.getMillisecondsInUtc() == that.withZone(UTC_ZONE).getMillis(); } return false; }
protected static DateTime computeExpirationTime( CacheableRequest request ) { CachePolicy policy = request.getCachePolicy(); return policy == null ? null : request.getTimeLoaded().plus(policy.getTimeToLive(), TimeUnit.MILLISECONDS); }
@Test public void shouldCreateDateFromInputStreamContainingUtf8EncodingOfStringWithWellFormedDate() throws Exception { assertThat(factory.create(new ByteArrayInputStream(TODAY.getString().getBytes("UTF-8"))), is(TODAY)); assertThat(factory.create(new ByteArrayInputStream(LAST_YEAR.getString().getBytes("UTF-8"))), is(LAST_YEAR)); }
/** * Define the upper boundary value of a range. * * @param literal the literal value that is to be cast * @return the constraint builder; never null */ public CastAs<ConstraintBuilder> cast( DateTime literal ) { return new CastAsUpperBoundary(this, literal.toUtcTimeZone()); }
/** * {@inheritDoc} * * @see org.modeshape.graph.property.ValueFactory#create(org.modeshape.graph.property.DateTime) */ public BigDecimal create( DateTime value ) throws ValueFormatException { if (value == null) return null; return create(value.getMilliseconds()); }
/** * {@inheritDoc} * * @see java.lang.Comparable#compareTo(java.lang.Object) */ public int compareTo( Changes that ) { if (this == that) return 0; return this.getTimestamp().compareTo(that.getTimestamp()); }
/** * Define the right-hand side of a comparison. * * @param literal the literal value; * @return the constraint builder; never null */ public ConstraintBuilder literal( DateTime literal ) { return comparisonBuilder.is(operator, literal.toUtcTimeZone()); }
this.expirationTime = expirationTime != null ? expirationTime.getMilliseconds() : Long.MAX_VALUE;