Package org.geotools.util

Examples of org.geotools.util.DateRange


                buff.append(",");
            }
            timeMetadata = buff.substring(0, buff.length() - 1).replaceAll("\\[", "")
                    .replaceAll("\\]", "").replaceAll(" ", "");
        } else if (DimensionPresentation.CONTINUOUS_INTERVAL == dimension.getPresentation()) {
            DateRange interval = getMinMaxTimeInterval(values);
            buff.append(df.format(interval.getMinValue()));
            buff.append("/");
            buff.append(df.format(interval.getMaxValue()));
            buff.append("/PT1S");
            timeMetadata = buff.toString();
        } else if (DimensionPresentation.DISCRETE_INTERVAL == dimension.getPresentation()) {
            DateRange interval = getMinMaxTimeInterval(values);
            buff.append(df.format(interval.getMinValue()));
            buff.append("/");
            buff.append(df.format(interval.getMaxValue()));
            buff.append("/");
           
            final BigDecimal resolution = dimension.getResolution();
            if (resolution != null) {
                // resolution has been provided
View Full Code Here


        if(maxValue instanceof DateRange) {
            max = ((DateRange) maxValue).getMaxValue();
        } else {
            max = (Date) maxValue;
        }
        return new DateRange(min, max);
    }
View Full Code Here

            final TimePositionType timePosition =
                Gml4wcsFactory.eINSTANCE.createTimePositionType();
            timePosition.setValue(tPos);
            timeSequence.getTimePosition().add(timePosition);
        } else if(tPos instanceof DateRange){
            DateRange range = (DateRange) tPos;
            final TimePeriodType timePeriod = Wcs10Factory.eINSTANCE.createTimePeriodType();
            final TimePositionType start = Gml4wcsFactory.eINSTANCE.createTimePositionType();
            start.setValue(range.getMinValue());
            timePeriod.setBeginPosition(start);
            final TimePositionType end = Gml4wcsFactory.eINSTANCE.createTimePositionType();
            end.setValue(range.getMaxValue());
            timePeriod.setEndPosition(end);
            timeSequence.getTimePeriod().add(timePeriod);
        }
    }
View Full Code Here

   
    public void testReducedAccuracyYear() throws Exception {
      Calendar c = new GregorianCalendar();
      c.setTimeZone(TimeKvpParser.UTC_TZ);
     
      DateRange year = (DateRange) TimeKvpParser.getFuzzyDate("2000");
      c.clear();
      c.set(Calendar.YEAR, 2000);
      assertRangeStarts(year, c.getTime());
      c.set(Calendar.YEAR, 2001);
      c.add(Calendar.MILLISECOND, -1);
View Full Code Here

    public void testReducedAccuracyHour() throws Exception {
        Calendar c = new GregorianCalendar();
        c.setTimeZone(TimeKvpParser.UTC_TZ);
        c.clear();
       
        DateRange hour = (DateRange) TimeKvpParser.getFuzzyDate("2000-04-04T12Z");
        c.set(Calendar.YEAR, 2000);
        c.set(Calendar.MONTH, 3); // 0-indexed
        c.set(Calendar.DAY_OF_MONTH, 4);
        c.set(Calendar.HOUR_OF_DAY, 12);
        assertRangeStarts(hour, c.getTime());
View Full Code Here

        TimeKvpParser timeKvpParser = new TimeKvpParser("TIME");
        List l = new ArrayList((CollectiontimeKvpParser.parse(CONTINUOUS_PERIOD));
        // Verify that the list contains at least one element.
        assertFalse(l.isEmpty());
        assertTrue(l.get(0) instanceof DateRange);
        final DateRange range=(DateRange) l.get(0);
        assertEquals(format.parse("2007-01-01T12Z"), range.getMinValue());
        Date end = format.parse("2007-01-31T13Z");
        end.setTime(end.getTime() - 1);
        assertEquals(end, range.getMaxValue());
    }
View Full Code Here

        TimeKvpParser timeKvpParser = new TimeKvpParser("TIME");
        List l = new ArrayList((CollectiontimeKvpParser.parse(CONTINUOUS_PERIOD+",2007-02-01T12Z"));
        // Verify that the list contains at least one element.
        assertFalse(l.isEmpty());
        assertTrue(l.get(0) instanceof DateRange);
        final DateRange range=(DateRange) l.get(0);
        assertEquals(format.parse("2007-01-01T12Z"), range.getMinValue());
        Date end = format.parse("2007-01-31T13Z");
        end.setTime(end.getTime() - 1);
        assertEquals(end, range.getMaxValue());
       
        assertRange((DateRange)l.get(1), format.parse("2007-02-01T12Z"), format.parse("2007-02-01T13Z"));
    }
View Full Code Here

            "2007-01-12T12Z,2007-01-17T12Z,2007-01-01T12Z/2007-01-15T12Z"));
        // Verify that the list contains at least one element.
        assertFalse(l.isEmpty());
        assertTrue(l.size()==1);
        assertTrue(l.get(0) instanceof DateRange);
        final DateRange range=(DateRange) l.get(0);
        assertRange(range, format.parse("2007-01-01T12Z"), format.parse("2007-01-31T13Z"));
    }
View Full Code Here

        TimeKvpParser timeKvpParser = new TimeKvpParser("TIME");
        GregorianCalendar cal = new GregorianCalendar();
        cal.setTimeZone(TimeZone.getTimeZone("GMT"));
       
        // base assertion - 0001 is year 1
        DateRange date = (DateRange) ((List)timeKvpParser.parse("01-06-01")).get(0);
        cal.setTime(date.getMinValue());
        assertEquals(1, cal.get(Calendar.YEAR));
        assertEquals(GregorianCalendar.AD, cal.get(Calendar.ERA));
       
        date = (DateRange) ((List)timeKvpParser.parse("00-06-01")).get(0);
        cal.setTime(date.getMinValue());
        // calendar calls it year 1, ISO spec means it's year 0
        // but we're just parsing here...
        assertEquals(1, cal.get(Calendar.YEAR));
        assertEquals(GregorianCalendar.BC, cal.get(Calendar.ERA));
       
        // so, the next year should be 2
        date = (DateRange) ((List)timeKvpParser.parse("-01-06-01")).get(0);
        cal.setTime(date.getMinValue());
        assertEquals(2, cal.get(Calendar.YEAR));
        assertEquals(GregorianCalendar.BC, cal.get(Calendar.ERA));
       
        // now, big negative year compliance (see the spec, appendix D 2.2, pp 57-58)
        date = (DateRange) ((List)timeKvpParser.parse("-18000-06-01")).get(0);
        cal.setTime(date.getMinValue());
        assertEquals(18001, cal.get(Calendar.YEAR));
        assertEquals(GregorianCalendar.BC, cal.get(Calendar.ERA));
    }
View Full Code Here

TOP

Related Classes of org.geotools.util.DateRange

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.