org.eclipse.stardust.common
Class DateUtils

java.lang.Object
  extended by org.eclipse.stardust.common.DateUtils

public class DateUtils
extends java.lang.Object

This utility class provides convenience methods for date / time related conversions and checks.

Version:
$Revision$
Author:
ubirkemeyer

Constructor Summary
DateUtils()
           
 
Method Summary
static java.lang.String formatDate(java.util.Date date)
          Returns a String representation for given Date object using date formatter with default style for default locale.
static java.lang.String formatDateTime(java.util.Date date)
          Returns a String representation for given Date object.
static java.lang.String formatDurationAsString(double durationInHours)
          Returns the given duration in hours as formatted string.
Format is: hours:minutes:seconds h
Example : 1:05:20 h
static java.lang.String formatTime(java.util.Date date)
          Returns a String representation for given Date object using time formatter with default style for default locale.
static java.text.SimpleDateFormat getInteractiveDateFormat()
          Factory which creates a SimpleDateFormat instance which can be used to format Dates to strings with pattern "yyyy/MM/dd hh:mm:ss".
static java.text.SimpleDateFormat getNoninteractiveDateFormat()
          Factory which creates a SimpleDateFormat instance which can be used to format Dates to strings with pattern "yyyy/MM/dd hh:mm:ss:SSS".
static long getTimestamp(java.util.Date date, long def)
          Returns number of milliseconds since January 1, 1970, 00:00:00 GMT represented by given Date object.
static boolean isValidISODateFormat(java.lang.String date)
          Checks if the input date conforms to an ISO date pattern (e.g.
static boolean isValidNonInteractiveFormat(java.lang.String date)
          Checks if the input date conforms to the non-interactive date format yyyy/MM/dd hh:mm:ss:SSS.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DateUtils

public DateUtils()
Method Detail

getNoninteractiveDateFormat

public static java.text.SimpleDateFormat getNoninteractiveDateFormat()
Factory which creates a SimpleDateFormat instance which can be used to format Dates to strings with pattern "yyyy/MM/dd hh:mm:ss:SSS".

Returns:
the SimpleDateFormat instance
See Also:
SimpleDateFormat

getInteractiveDateFormat

public static java.text.SimpleDateFormat getInteractiveDateFormat()
Factory which creates a SimpleDateFormat instance which can be used to format Dates to strings with pattern "yyyy/MM/dd hh:mm:ss".

Returns:
the SimpleDateFormat instance
See Also:
SimpleDateFormat

getTimestamp

public static long getTimestamp(java.util.Date date,
                                long def)
Returns number of milliseconds since January 1, 1970, 00:00:00 GMT represented by given Date object. If Date object is null the default value will be returned.

Parameters:
date - the Date object.
def - the default value used if Date object is null.
Returns:
number of milliseconds since January 1, 1970, 00:00:00 GMT.
See Also:
Date.getTime()

formatDateTime

public static java.lang.String formatDateTime(java.util.Date date)
Returns a String representation for given Date object. The String is a concatenation of date formatter and time formatter separated by single space, both using default style for default locale.

Parameters:
date - the Date object.
Returns:
String representation for Date object using default style for default locale. For null Date object an empty String will be returned.
See Also:
DateFormat.getDateInstance(), DateFormat.getTimeInstance()

formatDate

public static java.lang.String formatDate(java.util.Date date)
Returns a String representation for given Date object using date formatter with default style for default locale.

Parameters:
date - the Date object.
Returns:
String representation of date component for Date object using default style for default locale. For null Date object an empty String will be returned.
See Also:
DateFormat.getDateInstance()

formatTime

public static java.lang.String formatTime(java.util.Date date)
Returns a String representation for given Date object using time formatter with default style for default locale.

Parameters:
date - the Date object.
Returns:
String representation of time component for Date object using default style for default locale. For null Date object an empty String will be returned.
See Also:
DateFormat.getTimeInstance()

formatDurationAsString

public static java.lang.String formatDurationAsString(double durationInHours)
Returns the given duration in hours as formatted string.
Format is: hours:minutes:seconds h
Example : 1:05:20 h

Parameters:
durationInHours - the duration in hours.
Returns:
String representation of duration.

isValidISODateFormat

public static boolean isValidISODateFormat(java.lang.String date)
Checks if the input date conforms to an ISO date pattern (e.g. yyyy-MM-dd HH:mm:ss:SSS).

Parameters:
date - String representation of date.
Returns:
true if the date conforms to an ISO date pattern, false if it does not conform

isValidNonInteractiveFormat

public static boolean isValidNonInteractiveFormat(java.lang.String date)
Checks if the input date conforms to the non-interactive date format yyyy/MM/dd hh:mm:ss:SSS.

Parameters:
date - String representation of date.
Returns:
true if the date conforms to this pattern, false if it does not conform


Copyright © 2014 SunGard CSA LLC. All Rights Reserved.