use of org.geotoolkit.gml.xml.v311.TimePositionType in project geotoolkit by Geomatys.
the class TimePositionTypeTest method dateParsingTest.
@Test
public void dateParsingTest() throws Exception {
final String s1 = f1.format(date);
TimePositionType tp = new TimePositionType(s1);
assertEquals(date, tp.getDate());
final String s2 = f2.format(date);
tp = new TimePositionType(s2);
assertEquals(date, tp.getDate());
final String s3 = f3.format(date);
tp = new TimePositionType(s3);
final Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
final Date dateNoTime = cal.getTime();
assertEquals(dateNoTime, tp.getDate());
}
use of org.geotoolkit.gml.xml.v311.TimePositionType in project geotoolkit by Geomatys.
the class TimePositionTypeTest method setValueTest.
@Test
public void setValueTest() throws Exception {
String s = null;
TimePositionType tp = new TimePositionType(s);
final Date d = f3.parse("2010-01-01");
tp.setValue(d);
assertEquals(tp.getValue(), "2010-01-01");
final Date d2 = f2.parse("2010-01-01 01:01:02");
tp.setValue(d2);
assertEquals(tp.getValue(), "2010-01-01T01:01:02.000");
}
use of org.geotoolkit.gml.xml.v311.TimePositionType in project geotoolkit by Geomatys.
the class TimePeriodTypeTest method getTime3Test.
@Test
public void getTime3Test() throws Exception {
final String id = "id-1";
String snull = null;
TimeInstantType tb = new TimeInstantType(new TimePositionType("2008-11-01T02:00:00"));
TimeInstantType te = new TimeInstantType(new TimePositionType("2008-11-01T02:01:00"));
TimePeriodType tp = new TimePeriodType(id, snull);
tp.setBegin(new TimeInstantPropertyType(tb));
tp.setEnd(new TimeInstantPropertyType(te));
assertEquals(60000, tp.getTime());
tb = new TimeInstantType(new TimePositionType("2008-11-01T01:00:00"));
te = new TimeInstantType(new TimePositionType("2008-11-01T02:00:00"));
tp = new TimePeriodType(id, snull);
tp.setBegin(new TimeInstantPropertyType(tb));
tp.setEnd(new TimeInstantPropertyType(te));
assertEquals(3600000, tp.getTime());
tp = new TimePeriodType(id, snull);
tp.setBegin(new TimeInstantPropertyType(tb));
assertEquals(-1, tp.getTime());
tp = new TimePeriodType(id, snull);
tp.setEnd(new TimeInstantPropertyType(te));
assertEquals(-1, tp.getTime());
tp = new TimePeriodType(id, snull);
assertEquals(-1, tp.getTime());
}
Aggregations