Search in sources :

Example 31 with TimePositionType

use of org.geotoolkit.gml.xml.v321.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());
}
Also used : Calendar(java.util.Calendar) TimePositionType(org.geotoolkit.gml.xml.v311.TimePositionType) Date(java.util.Date)

Example 32 with TimePositionType

use of org.geotoolkit.gml.xml.v321.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");
}
Also used : TimePositionType(org.geotoolkit.gml.xml.v311.TimePositionType) Date(java.util.Date)

Example 33 with TimePositionType

use of org.geotoolkit.gml.xml.v321.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());
}
Also used : TimeInstantType(org.geotoolkit.gml.xml.v321.TimeInstantType) TimePeriodType(org.geotoolkit.gml.xml.v321.TimePeriodType) TimeInstantPropertyType(org.geotoolkit.gml.xml.v321.TimeInstantPropertyType) TimePositionType(org.geotoolkit.gml.xml.v321.TimePositionType)

Aggregations

Date (java.util.Date)17 TimePositionType (net.opengis.gml.v_3_2_1.TimePositionType)14 BinaryTemporalOpType (net.opengis.filter.v_2_0_0.BinaryTemporalOpType)13 FilterType (net.opengis.filter.v_2_0_0.FilterType)13 Test (org.junit.Test)12 TimePositionType (org.geotoolkit.gml.xml.v311.TimePositionType)11 ArrayList (java.util.ArrayList)10 TimePeriodType (net.opengis.gml.v_3_2_1.TimePeriodType)9 TimeInstantType (net.opengis.gml.v_3_2_1.TimeInstantType)7 TimePeriodType (org.geotoolkit.gml.xml.v311.TimePeriodType)7 FilterCapabilities (net.opengis.filter.v_2_0_0.FilterCapabilities)6 TimePositionType (org.geotoolkit.gml.xml.v321.TimePositionType)6 JAXBElement (javax.xml.bind.JAXBElement)4 TimePeriodType (org.geotoolkit.gml.xml.v321.TimePeriodType)4 StringWriter (java.io.StringWriter)3 List (java.util.List)3 TimeInstantType (org.geotoolkit.gml.xml.v311.TimeInstantType)3 StringReader (java.io.StringReader)2 Calendar (java.util.Calendar)2 Duration (javax.xml.datatype.Duration)2