public final class CmsDateConverter
extends java.lang.Object
限定符和类型 | 字段和说明 |
---|---|
static java.lang.String |
AM
A constant for am.
|
static java.lang.String |
PM
A constant for pm.
|
限定符和类型 | 方法和说明 |
---|---|
static java.lang.String |
cutSuffix(java.lang.String time)
Cuts the suffix (am or pm) from a given time String.
|
static java.lang.String |
dateToString(java.util.Date date)
Formats the provided date to a date only representation.
|
static java.util.Date |
getDateWithTime(java.util.Date date,
java.lang.String time)
Merges a given Date object with a given time String.
|
static java.lang.String |
getTime(java.util.Date date)
Returns the short time format of a given date as String.
|
static boolean |
is12HourPresentation()
Returns
true if the current date format is in the 12 hour
representation mode false otherwise. |
static boolean |
isAm(java.util.Date date)
Returns
true if an am is in the given date object false otherwise. |
static java.util.Date |
toDate(java.lang.String dateText)
Parses the provided String as a date.
|
static java.lang.String |
toDateString(java.util.Date date)
Formats the provided date as only a date format (dd/mm/yyyy).
|
static java.util.Date |
toDayDate(java.lang.String dateText)
Parses the provided String as a date.
|
static java.lang.String |
toString(java.util.Date date)
Formats the provided date.
|
static boolean |
validateDate(java.util.Date date)
Validates a time String if it matches one of the two regular expressions.
|
static boolean |
validateTime(java.lang.String time)
Validates a time String if it matches the regular expressions.
|
public static final java.lang.String AM
public static final java.lang.String PM
public static java.lang.String cutSuffix(java.lang.String time)
If the given String has less than 5 characters an dosen't contains an am or pm in it the original String is returned.
time
- the time String to cut the suffix frompublic static java.lang.String dateToString(java.util.Date date)
date
- the date to formatpublic static java.util.Date getDateWithTime(java.util.Date date, java.lang.String time)
Returns a null
if the given time format coudn't be parsed.
The expected time String should include the am pm information if the time format is in 12 hour presentation.
date
- the given Date object which time has to be settime
- the given time String which should be inserted into the Date Objectpublic static java.lang.String getTime(java.util.Date date)
date
- the date to get the short time format frompublic static boolean is12HourPresentation()
true
if the current date format is in the 12 hour
representation mode false
otherwise.true
if an am or a pm is in a new Date object false
otherwisepublic static boolean isAm(java.util.Date date)
true
if an am is in the given date object false
otherwise.date
- the date to checktrue
if an am is in the given Date object false
otherwisepublic static java.util.Date toDate(java.lang.String dateText) throws java.lang.Exception
First try to parse the String with the given time format.
If that fails try to parse the date with the browser settings.
dateText
- the string representing a datejava.lang.Exception
public static java.lang.String toDateString(java.util.Date date)
date
- the date to formatpublic static java.util.Date toDayDate(java.lang.String dateText) throws java.lang.Exception
First try to parse the String with the given time format.
If that fails try to parse the date with the browser settings.
dateText
- the string representing a datejava.lang.Exception
public static java.lang.String toString(java.util.Date date)
date
- the date to formatpublic static boolean validateDate(java.util.Date date)
Returns true
if the given date matches to one of the regular
expressions, false
otherwise.
date
- the date String to checktrue
if the given time matches to one of the regular expressions, false
otherwisepublic static boolean validateTime(java.lang.String time)
Returns true
if the given time matches the regular
expressions, false
otherwise.
time
- the time String to checktrue
if the given time matches the regular expressions, false
otherwise