Dashboard Builder Commons 6.2.0.Beta2

org.jboss.dashboard.commons.text
Class DateFormatUtil

java.lang.Object
  extended by org.jboss.dashboard.commons.text.DateFormatUtil

public class DateFormatUtil
extends Object

Utilities for formatting and parsing dates.


Method Summary
static String dateToOracleStr(Timestamp ts)
          Contains some Oracle specific fixes to the timestamp.
static String dateToStr(Date date)
          Formats a Date into a date string.
static String dateToUTCStr(Date UTCDate)
          Turns a UTCTime in a java.util.Date object into a String object.
static boolean isLongDate(Timestamp date)
          Tells whether Timestamp is in long format: with hours, minutes and seconds fields.
static boolean isValidDate(String text)
          Tells whether date/time string is in the format "dd/MM/yyyy".
static Timestamp nativeStrToTimestamp(String text)
          Parse a native date/time string.
static Timestamp strToTimestamp(String text)
          Parse a date/time string.
static String timeToStr(Date date)
          Formats a Date into a time string.
static Date utcStrToDate(String UTCTime)
          Turns a UTCTime in string format into a java.util.Date object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isLongDate

public static boolean isLongDate(Timestamp date)
Tells whether Timestamp is in long format: with hours, minutes and seconds fields.

Parameters:
date - the time value to be tested
Returns:
true if this date is in long format; false otherwise

isValidDate

public static boolean isValidDate(String text)
                           throws ParseException
Tells whether date/time string is in the format "dd/MM/yyyy".

Parameters:
text - the date/time string to be tested
Returns:
true if this string is in "dd/MM/yyyy" format; false otherwise
Throws:
ParseException

timeToStr

public static String timeToStr(Date date)
Formats a Date into a time string. The result time string has the pattern "HH:mm:ss"

Parameters:
date - the time value to be formatted into a time string.
Returns:
the formatted time string.

dateToStr

public static String dateToStr(Date date)
Formats a Date into a date string. The result time string has the pattern "dd/MM/yyyy"

Parameters:
date - the time value to be formatted into a date string.
Returns:
the formatted date string.

strToTimestamp

public static Timestamp strToTimestamp(String text)
                                throws ParseException
Parse a date/time string. The date/time string must be in "dd/MM/yyyy" format

Parameters:
text - The date/time string to be parsed
Returns:
A Timestamp, or null if the input could not be parsed
Throws:
ParseException - If the given string cannot be parsed as a date

nativeStrToTimestamp

public static Timestamp nativeStrToTimestamp(String text)
                                      throws ParseException
Parse a native date/time string. The date/time string must be in "yyyy/MM/dd" format

Parameters:
text - The date/time string to be parsed
Returns:
A Timestamp, or null if the input could not be parsed
Throws:
ParseException - If the given string cannot be parsed as a date

dateToUTCStr

public static String dateToUTCStr(Date UTCDate)
                           throws ParseException
Turns a UTCTime in a java.util.Date object into a String object.

Parameters:
UTCDate - Date with a UTCTime date
Returns:
Date
Throws:
ParseException

utcStrToDate

public static Date utcStrToDate(String UTCTime)
                         throws ParseException
Turns a UTCTime in string format into a java.util.Date object

Parameters:
UTCTime - String with a UTCTime date
Returns:
Date
Throws:
ParseException

dateToOracleStr

public static String dateToOracleStr(Timestamp ts)
Contains some Oracle specific fixes to the timestamp. Hopefully I've fixed it so it isn't incompatible with others now! Also turns nulls into "null"s.

Returns:
the formatted time string.

Dashboard Builder Commons 6.2.0.Beta2

Copyright © 2012-2014 JBoss by Red Hat. All Rights Reserved.