org.n52.security.common.util
Class DateUtil

java.lang.Object
  extended by org.n52.security.common.util.DateUtil

public final class DateUtil
extends Object

Author:
Marko Reiprecht
See Also:
for possible iso patterns.

Constructor Summary
DateUtil()
           
 
Method Summary
static Calendar createCalendar(TimeZone zone, int year, int month, int dayofMonth, int hour, int min, int sec, int milli)
          Creates a new CalendarInstance in the given time zone for the given time settings.
static Calendar createUTCCalendar(int year, int month, int dayofMonth, int hour, int min, int sec, int milli)
          Creates a new CalendarInstance in the UTC time zone for the given time settings.
static TimeZone createUTCTimeZone(int offset)
          Creates UTC Timezone with given offset in millisec.
static TimeZone createUTCTimeZone(int hour, int minutes)
          Creates UTC Timezone with given hour , minute offset.
static Calendar fromISOString(String isoStr)
          Method parses a iso formated date.
static String tofullISOString(Calendar date)
          Method formats a date to an iso formated string.
static String tofullISOString(Date date)
          Method formats a date to an iso formated string.
static String toUTCISOString(Calendar date)
          Method formats a date to an iso formated string.
static String toUTCISOString(Date date)
          Method formats a date to an iso formated string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DateUtil

public DateUtil()
Method Detail

createUTCCalendar

public static Calendar createUTCCalendar(int year,
                                         int month,
                                         int dayofMonth,
                                         int hour,
                                         int min,
                                         int sec,
                                         int milli)
Creates a new CalendarInstance in the UTC time zone for the given time settings.

Parameters:
year - the year
month - the month (starting with index 1 (this is not like the Calendar.set(int, int, int, int, int, int) method).
dayofMonth - the day of month.
hour - the hour.
min - the min.
sec - the sec.
milli - the milli.
Returns:
a new calendar.

createCalendar

public static Calendar createCalendar(TimeZone zone,
                                      int year,
                                      int month,
                                      int dayofMonth,
                                      int hour,
                                      int min,
                                      int sec,
                                      int milli)
Creates a new CalendarInstance in the given time zone for the given time settings.

Parameters:
zone - time zone.
year - the year
month - the month (starting with index 1 (this is not like the Calendar.set(int, int, int, int, int, int) method).
dayofMonth - the day of month.
hour - the hour.
min - the min.
sec - the sec.
milli - the milli.
Returns:
a new calendar.

createUTCTimeZone

public static TimeZone createUTCTimeZone(int offset)
Creates UTC Timezone with given offset in millisec.


createUTCTimeZone

public static TimeZone createUTCTimeZone(int hour,
                                         int minutes)
Creates UTC Timezone with given hour , minute offset. the minutes are always added to the absolute hour value, but the sign of the hour value is used to calculate sign of the offset.

Parameters:
hour - the hour offset.
minutes - the minutes in the hour.
Returns:
a UTC Timezone.

fromISOString

public static Calendar fromISOString(String isoStr)
                              throws IllegalArgumentException
Method parses a iso formated date. e.g: 2009-11-17T13:28:17+0100 (with timezone offset) or 2009-11-17T13:28:17Z (as UTC time)

Parameters:
isoStr - the iso format string.
Returns:
Date the parsed date.
Throws:
IllegalArgumentException - if isoStr can't be parsed.

toUTCISOString

public static String toUTCISOString(Calendar date)
Method formats a date to an iso formated string. It will always produce the utc iso format, e.g.: 2009-11-17T13:28:17.235Z.

Parameters:
date -
Returns:

toUTCISOString

public static String toUTCISOString(Date date)
Method formats a date to an iso formated string. It will always produce the utc iso format, e.g.: 2009-11-17T13:28:17.235Z.


tofullISOString

public static String tofullISOString(Date date)
Method formats a date to an iso formated string. It will always produce the full iso format, e.g.: 2009-11-17T13:28:17.235+0100.

Parameters:
date - the date.
Returns:
String.

tofullISOString

public static String tofullISOString(Calendar date)
Method formats a date to an iso formated string. It will always produce the full iso format, e.g.: 2009-11-17T13:28:17.235+0100.

Parameters:
date - the date.
Returns:
String.


Copyright © 2004–2014 52north.org. All rights reserved.