fr.cnes.sitools.util
Class DateUtils

java.lang.Object
  extended by fr.cnes.sitools.util.DateUtils

public final class DateUtils
extends java.lang.Object

Custom DateUtils class for SITools2. Created from the DateUtils from Restlet 2.0.5

Author:
m.gond

Field Summary
static java.lang.String FORMAT_ISO_8601_WITHOUT_TIME_ZONE
          ISO_8601 format without time zone
static java.lang.String SITOOLS_DATE_FORMAT
          Default date format for date exchange between the server and the client in all the Sitools2 application
static java.lang.String SITOOLS_TIME_FORMAT
          Default date format for date exchange between the server and the client in all the Sitools2 application
 
Method Summary
static java.util.Date add(java.util.Date date, int field, int amount)
          Adds or subtracts the specified amount of time to the given calendar field, based on the calendar's rules.
static java.lang.String format(java.util.Date date)
          Formats a Date according to the default date format.
static java.lang.String format(java.util.Date date, java.lang.String format)
          Formats a Date according to the first format in the array.
static java.lang.String formatTime(java.util.Date date)
          Formats a Date according to the default date format.
static java.util.Date parse(java.lang.String date)
          Parses a formatted date into a Date object with the default date format.
static java.util.Date parse(java.lang.String date, java.lang.String format)
          Parses a formatted date into a Date object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SITOOLS_DATE_FORMAT

public static final java.lang.String SITOOLS_DATE_FORMAT
Default date format for date exchange between the server and the client in all the Sitools2 application

See Also:
Constant Field Values

SITOOLS_TIME_FORMAT

public static final java.lang.String SITOOLS_TIME_FORMAT
Default date format for date exchange between the server and the client in all the Sitools2 application

See Also:
Constant Field Values

FORMAT_ISO_8601_WITHOUT_TIME_ZONE

public static final java.lang.String FORMAT_ISO_8601_WITHOUT_TIME_ZONE
ISO_8601 format without time zone

See Also:
Constant Field Values
Method Detail

format

public static java.lang.String format(java.util.Date date)
Formats a Date according to the default date format.

Parameters:
date - The date to format.
Returns:
The formatted date.

formatTime

public static java.lang.String formatTime(java.util.Date date)
Formats a Date according to the default date format.

Parameters:
date - The date to format.
Returns:
The formatted date.

format

public static java.lang.String format(java.util.Date date,
                                      java.lang.String format)
Formats a Date according to the first format in the array.

Parameters:
date - The date to format.
format - The date format to use.
Returns:
The formatted date.

parse

public static java.util.Date parse(java.lang.String date)
                            throws java.text.ParseException
Parses a formatted date into a Date object with the default date format.

Parameters:
date - The date to parse.
Returns:
The parsed date.
Throws:
java.text.ParseException - if there is an error while parsing the date

parse

public static java.util.Date parse(java.lang.String date,
                                   java.lang.String format)
                            throws java.text.ParseException
Parses a formatted date into a Date object.

An IllegalArgumentException is raised when date is empty or null

Parameters:
date - The date to parse.
format - The format of the date string
Returns:
The parsed date.
Throws:
java.text.ParseException - if there is an error while parsing the date

add

public static java.util.Date add(java.util.Date date,
                                 int field,
                                 int amount)
Adds or subtracts the specified amount of time to the given calendar field, based on the calendar's rules. For example, to subtract 5 days from the current time of the calendar, you can achieve it by calling:

Parameters:
date - the Date
field - the calendar field. A constant of the class Calendar
amount - the amount of date or time to be added to the field.
Returns:
a Date corresponding to date + minutes


Copyright © 2010-2013 CNES. All Rights Reserved.