it.geosolutions.tools.commons.time
Class TimeParser

java.lang.Object
  extended by it.geosolutions.tools.commons.time.TimeParser

public class TimeParser
extends Object

Parses the time parameter of the request. The date, time and period are expected to be formatted according ISO-8601 standard.

Author:
Simone Giannecchini, GeoSolutions SAS, Carlo Cancellieri - carlo.cancellieri@geo-solutions.it

Constructor Summary
TimeParser()
           
 
Method Summary
static List<Date> parse(String value)
          Parses the date given in parameter.
static long parsePeriod(String period)
          Parses the increment part of a period and returns it in milliseconds.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TimeParser

public TimeParser()
Method Detail

parse

public static List<Date> parse(String value)
                        throws ParseException
Parses the date given in parameter. The date format should comply to ISO-8601 standard. The string may contains either a single date, or a start time, end time and a period. In the first case, this method returns a singleton containing only the parsed date. In the second case, this method returns a list including all dates from start time up to the end time with the interval specified in the value string.

Parameters:
value - The date, time and period to parse.
Returns:
A list of dates, or an empty list of the value string is null or empty.
Throws:
ParseException - if the string can not be parsed.

parsePeriod

public static long parsePeriod(String period)
                        throws ParseException
Parses the increment part of a period and returns it in milliseconds.

Parameters:
period - A string representation of the time increment according the ISO-8601:1988(E) standard. For example: "P1D" = one day.
Returns:
The increment value converted in milliseconds.
Throws:
ParseException - if the string can not be parsed.


Copyright © 2011-2012 GeoSolutions. All Rights Reserved.