@Override public <T> T convert(Object source, Class<T> target) throws Exception { Instant instant = (Instant) source; return (T) instant.getPosition().getDate(); } };
public DefaultPeriod(Instant begining, Instant ending) { if (begining.relativePosition(ending).equals(RelativePosition.BEFORE)) { this.begining = begining; this.ending = ending; } /*if (((DefaultInstant) begining).getPosition().getDate().before(((DefaultInstant) ending).getPosition().getDate())) { this.begining = begining; this.ending = ending; } */ else { throw new IllegalArgumentException( "The temporal position of the beginning of the period must be less than (i.e. earlier than) the temporal position of the end of the period"); } }
/** Test of getBegunBy method, of class DefaultInstant. */ @Test public void testGetBegunBy() { Collection<Period> result = instant1.getBegunBy(); assertEquals(instant2.getBegunBy(), result); }
/** * Infers a value from the extent as a {@link Date} object and computes the union with a lower or upper bounds. * * @param bound the current lower ({@code begin == true}) or upper ({@code begin == false}) bound. * @param begin {@code true} for the start time, or {@code false} for the end time. */ private static Date union(final Date bound, final TemporalPrimitive extent, final boolean begin) { final Instant instant; if (extent instanceof Instant) { instant = (Instant) extent; } else if (extent instanceof Period) { instant = begin ? ((Period) extent).getBeginning() : ((Period) extent).getEnding(); } else { return bound; } final Date t = instant.getDate(); if (t != null && (bound == null || (begin ? t.before(bound) : t.after(bound)))) { return t; } return bound; }
/** * Constructs a new instance initialized with the values from the specified metadata object. * This is a <cite>shallow</cite> copy constructor, since the other metadata contained in the * given object are not recursively copied. * * @param object The Instant to copy values from, or {@code null} if none. * * @see #castOrCopy(Instant) */ private DefaultInstant(final Instant object) { if (object != null) { this.date = object.getDate(); this.temporalPosition = object.getTemporalPosition(); } else { this.date = null; this.temporalPosition = null; } }
if (timeobject.getDate() == null || instantOther.getDate() == null) { return null; } else if (timeobject.getDate().before(instantOther.getDate())) { return RelativePosition.BEFORE; } else { return (timeobject.getDate().compareTo(instantOther.getDate()) == 0) ? RelativePosition.EQUALS : RelativePosition.AFTER; if (timeobject.getEnding().getDate().before(instantarg.getDate())) { return RelativePosition.BEFORE; } else if (timeobject.getEnding().getDate().compareTo(instantarg.getDate()) == 0) { return RelativePosition.ENDED_BY; } else if (timeobject.getBeginning().getDate().before(instantarg.getDate()) && timeobject.getEnding().getDate().after(instantarg.getDate())) { return RelativePosition.CONTAINS; } else { return (timeobject.getBeginning().getDate().compareTo(instantarg.getDate()) == 0) ? RelativePosition.BEGUN_BY : RelativePosition.AFTER; if (instantarg.getEnding().getDate().before(timeobject.getDate())) { return RelativePosition.AFTER; } else if (instantarg.getEnding().getDate().compareTo(timeobject.getDate()) == 0) { return RelativePosition.ENDS; } else if (instantarg.getBeginning().getDate().before(timeobject.getDate()) && instantarg.getEnding().getDate().after(timeobject.getDate())) { return RelativePosition.DURING; } else { return (instantarg.getBeginning().getDate().compareTo(timeobject.getDate()) == 0) ? RelativePosition.BEGINS : RelativePosition.BEFORE; if (timeobject.getEnding().getDate().before(instantarg.getBeginning().getDate())) { return RelativePosition.BEFORE;
public Object getProperty(Object object, QName name) { Period timePeriod = (Period) object; if (timePeriod == null) { return null; } if (name.getLocalPart().equals("BeginPosition")) { return timePeriod.getBeginning().getPosition(); } if (name.getLocalPart().equals("EndPosition")) { return timePeriod.getEnding().getPosition(); } return null; } }
public DefaultPeriod(Instant begining, Instant ending) { if (begining.relativePosition(ending).equals(RelativePosition.BEFORE)) { this.begining = begining; this.ending = ending; } /*if (((DefaultInstant) begining).getPosition().getDate().before(((DefaultInstant) ending).getPosition().getDate())) { this.begining = begining; this.ending = ending; } */else { throw new IllegalArgumentException("The temporal position of the beginning of the period must be less than (i.e. earlier than) the temporal position of the end of the period"); } }
/** Test of setBegunBy method, of class DefaultInstant. */ @Test public void testSetBegunBy() { Collection<Period> result = instant1.getBegunBy(); Collection<Period> begunby = null; ((DefaultInstant) instant1).setBegunBy(begunby); assertEquals(instant1.getBegunBy(), result); }
public Object getProperty(Object object, QName name) { Period timePeriod = (Period) object; if (timePeriod == null) { return null; } if (name.getLocalPart().equals("beginPosition")) { return timePeriod.getBeginning().getPosition(); } if (name.getLocalPart().equals("endPosition")) { return timePeriod.getEnding().getPosition(); } return null; } }
diff = Math.min(Math.abs(((Instant) other).getDate().getTime() - ((Instant) this).getDate().getTime()), Math.abs(((Instant) this).getDate().getTime() - ((Instant) other).getDate().getTime())); } else { if (this instanceof Instant && other instanceof Period) { diff = Math.min(Math.abs(((Period) other).getBeginning().getDate().getTime() - ((Instant) this).getDate().getTime()), Math.abs(((Period) other).getEnding().getDate().getTime() - ((Instant) this).getDate().getTime())); } else { if (this instanceof Period && other instanceof Instant) { diff = Math.min(Math.abs(((Instant) other).getDate().getTime() - ((Period) this).getEnding().getDate().getTime()), Math.abs(((Instant) other).getDate().getTime() - ((Period) this).getBeginning().getDate().getTime())); } else { if (this instanceof Period && other instanceof Period) { diff = Math.min(Math.abs(((Period) other).getEnding().getDate().getTime() - ((Period) this).getBeginning().getDate().getTime()), Math.abs(((Period) other).getBeginning().getDate().getTime() - ((Period) this).getEnding().getDate().getTime()));
public DefaultPeriod(Instant begining, Instant ending) { if (begining.relativePosition(ending).equals(RelativePosition.BEFORE)) { this.begining = begining; this.ending = ending; } /*if (((DefaultInstant) begining).getPosition().getDate().before(((DefaultInstant) ending).getPosition().getDate())) { this.begining = begining; this.ending = ending; } */else { throw new IllegalArgumentException("The temporal position of the beginning of the period must be less than (i.e. earlier than) the temporal position of the end of the period"); } }
out.write("'" + ts + "'"); } else if (literal instanceof Instant) { java.util.Date date = ((Instant) literal).getPosition().getDate(); Timestamp ts = new java.sql.Timestamp(date.getTime()); out.write("'" + ts + "'");
/** * Test of equals method, of class DefaultInstant. */ @Test public void testEquals() { cal.set(2000, 1, 1); assertFalse(instant1.equals(null)); assertEquals(cal.getTime().getTime(), instant1.getDate().getTime()); assertFalse(instant1.equals(instant2)); }
(RelativePosition.BEFORE.equals(begining.relativePosition(ending)) || RelativePosition.EQUALS.equals(begining.relativePosition(ending)))) { this.begining = begining; this.ending = ending;
/** Test of getPosition method, of class DefaultInstant. */ @Test public void testGetPosition() { Position result = instant1.getPosition(); assertFalse(instant2.getPosition().equals(result)); }
output = dateToText(period.getBeginning().getPosition().getDate(), output); output.append("/"); output = dateToText(period.getEnding().getPosition().getDate(), output);
/** Test of setPosition method, of class DefaultInstant. */ @Test public void testSetPosition() { Position result = instant1.getPosition(); Position position = new DefaultPosition(new Date()); ((DefaultInstant) instant1).setPosition(position); assertFalse(instant1.getPosition().equals(result)); }
void visitEnd(Period p, Object extraData) { filterFactory.literal(p.getEnding().getPosition().getDate()).accept(this, extraData); }