jodd.datetime
Class JDateTime

java.lang.Object
  extended byjodd.datetime.JDateTime
All Implemented Interfaces:
java.lang.Comparable

public class JDateTime
extends java.lang.Object
implements java.lang.Comparable

Universal all-in-one date and time class that uses Astronomical Julian Dates for time calculations. Guarantied precision is up to 0.001 sec.

JDateTime contains date/time information for current day. By default, behaviour and formats are set to ISO standard, although this may be changed.

JDateTime can be set in many different ways by using setXxx() methods or equivalent constructors. Moreover, it may be set from an instance of any available java date-time class. This functionality can be easily enhanced for any custom date/time class. Furthermore, JDateTime can be used for generation of any such date/time class.

Rolling dates with JDateTime is easy. For this JDateTime contains many addXxx() methods. Time can be added or subtracted with any value or more values at once. All combinations are valid. Calculations also performs month fixes by default.

JDateTime behaviour is set by several attributes (or parameters). Each one contains 2 values: one is the default value, used by all instances of JDateTime and the other one is just for a specific instance of JDateTime. This means that it is possible to set behavior of all instances at once or of one particular instance.

Bellow is the list of behavior attributes:

Optimization: although based on heavy calculations, JDateTime works significantly faster then java's Calendars. Since JDateTime doesn't use lazy initialization, setXxx() method is slower. However, this doesn't have much effect to the global performances: settings are not used without gettings. As soon as any other method is used (getXxx() or addXxx()) performances of JDateTime becomes significantly better.


Field Summary
static JulianDateStamp JD_1970
          Julian Date for 1970-01-01.
 
Constructor Summary
JDateTime()
          Constructor that sets current local date and time.
JDateTime(DateTimeStamp dts)
          Contructs JDateTime from DateTimeStamp.
JDateTime(int year, int month, int day)
          Constructor that sets just date.
JDateTime(int year, int month, int day, int hour, int minute, double second)
          Constructor that set date and time.
JDateTime(JulianDateStamp jds)
          Contructs JDateTime from JulianDateStamp.
JDateTime(long milis)
          Constructor that sets current time specified as time in milliseconds, from the midnight, January 1, 1970 UTC.
JDateTime(java.lang.Object o)
          Contructs JDateTime from various objects.
 
Method Summary
 void add(int year, int month, int day)
          Adds date, leaving time unchanged, with preset value of monthFix.
 void add(int year, int month, int day, boolean monthFix)
          Adds date, leaving time unchanged.
 void add(int year, int month, int day, int hour, int minute, double second)
          Performs time adding with preset value of monthFix attribute.
 void add(int year, int month, int day, int hour, int minute, double second, boolean monthFix)
          Adds time to current time.
 void addDay(int d)
          Adds days, with preset value of monthFix.
 void addDay(int d, boolean monthFix)
          Adds days.
 void addHour(int h)
          Adds hours, with preset value of monthFix.
 void addHour(int h, boolean monthFix)
          Adds hours.
 void addMillisecond(int ms)
          Adds milliseconds, with preset value of monthFix.
 void addMillisecond(int ms, boolean monthFix)
          Adds milliseconds.
 void addMinute(int m)
          Adds minutes, with preset value of monthFix.
 void addMinute(int m, boolean monthFix)
          Adds minutes.
 void addMonth(int m)
          Adds month, with preset value of monthFix.
 void addMonth(int m, boolean monthFix)
          Adds month.
 void addSecond(double s)
          Adds seconds, with preset value of monthFix.
 void addSecond(double s, boolean monthFix)
          Adds seconds.
 void addTime(int hour, int minute, double second)
          Adds time, with preset value of monthFix.
 void addTime(int hour, int minute, double second, boolean monthFix)
          Adds time.
 void addYear(int y)
          Adds year, with preset value of monthFix.
 void addYear(int y, boolean monthFix)
          Adds year.
 int compareTo(java.lang.Object gt)
          Compares current JDateTime object with another one, up to 1 millisecond.
 java.lang.String get()
          Get current date/time in default format.
 java.lang.String get(java.lang.String template)
          Get current date/time in specified format.
 java.util.Calendar getCalendarInstance()
          Shortcut for getInstance() that builds and returns Calendar instance.
 java.util.Date getDateInstance()
          Shortcut for getInstance() that builds and returns Date instance.
 DateTimeStamp getDateTimeStamp()
          Returns new object generic time stamp.
 int getDay()
          Returns current day of month.
 int getDayOfMonth()
          Returns current day of month.
 int getDayOfWeek()
          Returns current day of week.
 int getDayOfYear()
          Returns current day of year.
 int getFirstDayOfWeek()
          Returns the first day of the week.
 java.lang.String getFormatTemplate()
          Returns actual format template.
 java.util.GregorianCalendar getGregorianCalendarInstace()
          Shortcut for getInstance() that builds and returns GregorianCalendar instance.
 int getHour()
          Returns current hour.
 java.lang.Object getInstance(java.lang.Class c)
          Stores time to a new instance of desired class, by using converters.
 JDateTime getJDateTimeInstance()
          Shortcut for getInstance() that builds and returns new JDateTime instance with the date/time set as the original one.
 JulianDateStamp getJulianDate()
          Returns Julian Date stamp.
 int getMillisecond()
          Returns current milliseconds.
 int getMinimalDaysInFirstWeek()
          Returns minimal number of days of the first week.
 int getMinute()
          Returns current minutes.
 int getMonth()
          Returns current month.
 boolean getMonthFix()
          Returns actual mont fix value.
 int getMonthLength()
          Returns the length of the current month in days.
 int getMonthLength(int m)
          Returns the length of the specified month in days.
 int getMustHaveDayOfFirstWeek()
          Returns must have day of the 1st week.
 JdtNames getNames()
          Returns actual date time names.
 double getSecond()
          Return current secodns.
 java.sql.Date getSqlDateInstace()
          Shortcut for getInstance() that builds and returns java.sql.Date instance.
 java.sql.Timestamp getSqlTimestampInstance()
          Shortcut for getInstance() that builds and returns java.sql.Timestamp instance.
 int getWeekOfMonth()
           
 int getWeekOfYear()
          Returns current week of year.
 int getYear()
          Returns current year.
 boolean isLeap()
          Returns current leap year flag.
static boolean isValid(java.lang.String s)
          Checks if some string represents a valid date.
static boolean isValid(java.lang.String s, java.lang.String template)
          Checks if some string represents a valid date.
 void loadFrom(java.lang.Object o)
          Loads time from an object by using registered converters.
static void register(java.lang.Class c, JdtConverter gtc)
          Registers a JdtConvertor for a specific class.
static void registerDefaults()
          Registers default converters.
static void resetDefaultFormatTemplate()
          Resets default format to JDateTime defaults format: YYYY-MM-DD hh:mm:s.m
static void resetDefaultMonthFix()
          Resets default month fix value to true.
static void resetDefaultNames()
          Resets default date time names to English.
static void resetDefaultWeekDefinition()
          Resets default week definition.
 void resetFormatTemplate()
          Resets current format template to default value.
 void resetMonthFix()
          Resets month fix value to default one.
 void resetNames()
          Reset current names to default values.
 void resetWeekDefintion()
          Resets week definition.
 void set()
          Sets current local date and time.
 void set(int year, int month, int day)
          Sets date, time is set to midnight (00:00:00.000).
 void set(int year, int month, int day, int hour, int minute, double second)
          Core method that sets date and time.
 void set(long milis)
          Sets the time based on current time in milliseconds.
 void set(java.lang.String s)
          Sets date/time from a string and default template.
 void set(java.lang.String s, java.lang.String template)
          Sets date/time from a string and specified template.
 void setDate(int year, int month, int day)
          Sets date, time remains unchanged.
 void setDateTimeStamp(DateTimeStamp t)
          Sets the new timestamp.
 void setDay(int d)
          Sets current day.
static void setDefaultFormatTemplate(java.lang.String newFormatTemplate)
          Sets default format template.
static void setDefaultFormatter(JdtFormatter f)
          Sets default formatter
static void setDefaultMonthFix(boolean v)
          Sets default month fix value.
static void setDefaultNames(JdtNames newNames)
          Sets default JDateTime names.
static void setDefaultWeekDefinition(int start, int must)
          Defines default week.
static void setDefaultWeekDefinitionAlt(int start, int min)
          Defines default week alternatively.
 void setFormatTemplate(java.lang.String newFormat)
          Sets current format template.
 void setHour(int h)
          Set current hour.
 void setJulianDate(JulianDateStamp jds)
          Sets current Julian Date.
 void setMillisecond(int m)
          Sets current millisecond.
 void setMinute(int m)
          Set current minute.
 void setMonth(int m)
          Sets current month.
 void setMonthFix(boolean v)
          Sets month fix value.
 void setNames(JdtNames newNames)
          Sets current date time names.
 void setSecond(double s)
          Sets current second and millisecond.
 void setSecond(int s)
          Sets current second.
 void setTime(int hour, int minute, double second)
          Sets time, date is unchanged.
 void setTimeStamp(DateTimeStamp t)
          Deprecated. use setDateTimeStamp() instead
 void setWeekDefinition(int start, int must)
          Defines week.
 void setWeekDefinitionAlt(int start, int min)
          Defines week alternatively.
 void setYear(int y)
          Sets current year.
 void storeTo(java.lang.Object o)
          Stores time to an existing instance of desired class, by using converters.
 java.lang.String toString()
          Returns date time string in YYYY-MM-DD hh:mm:s.m format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

JD_1970

public static final JulianDateStamp JD_1970
Julian Date for 1970-01-01.

Constructor Detail

JDateTime

public JDateTime(int year,
                 int month,
                 int day,
                 int hour,
                 int minute,
                 double second)
Constructor that set date and time.

Parameters:
year - year to set
month - month to set
day - day to set
hour - hours to set
minute - minutes to set
second - seconds to set
See Also:
set(int, int, int, int, int, double)

JDateTime

public JDateTime(int year,
                 int month,
                 int day)
Constructor that sets just date. Time is set to 00:00:00.

Parameters:
year - year to set
month - month to set
day - day to set
See Also:
set(int, int, int)

JDateTime

public JDateTime(long milis)
Constructor that sets current time specified as time in milliseconds, from the midnight, January 1, 1970 UTC.

Parameters:
milis - time in milliseconds, from the midnight, January 1, 1970 UTC
See Also:
set(long )

JDateTime

public JDateTime()
Constructor that sets current local date and time.


JDateTime

public JDateTime(java.lang.Object o)
Contructs JDateTime from various objects.

Parameters:
o - object from where to read date info

JDateTime

public JDateTime(DateTimeStamp dts)
Contructs JDateTime from DateTimeStamp.

Parameters:
dts - date time stamp

JDateTime

public JDateTime(JulianDateStamp jds)
Contructs JDateTime from JulianDateStamp.

Parameters:
jds - date time stamp
Method Detail

setJulianDate

public void setJulianDate(JulianDateStamp jds)
Sets current Julian Date. This is the core of the JDateTime class and it is used by all other classes. This method performs all calculations required for whole class.

Parameters:
jds - current julian date

set

public void set(int year,
                int month,
                int day,
                int hour,
                int minute,
                double second)
Core method that sets date and time. All others set() methods use this one. Milliseconds are truncated after 3rd digit.

Parameters:
year - year to set
month - month to set
day - day to set
hour - hour to set
minute - minute to set
second - second to set

getJulianDate

public JulianDateStamp getJulianDate()
Returns Julian Date stamp.

Returns:
Julian Date stamp

compareTo

public int compareTo(java.lang.Object gt)
Compares current JDateTime object with another one, up to 1 millisecond.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
gt - JDateTime to compare
Returns:
-1 if the current object is less than the argument, 0 if the argument is equal, and 1 if the current object is greater than the argument

add

public void add(int year,
                int month,
                int day,
                int hour,
                int minute,
                double second,
                boolean monthFix)
Adds time to current time. The main add method. All other add() methods must use this one.

There are 2 different kind of addings, when months are added:

Parameters:
year - delta year
month - delta month
day - delta days
hour - delta hours
minute - delta minutes
second - delta seconds
monthFix - true for month fixing, false otherwise

add

public void add(int year,
                int month,
                int day,
                int hour,
                int minute,
                double second)
Performs time adding with preset value of monthFix attribute.

Parameters:
year - delta year
month - delta month
day - delta days
hour - delta hours
minute - delta minutes
second - delta seconds
See Also:
add(int, int, int, int, int, double, boolean)

add

public void add(int year,
                int month,
                int day,
                boolean monthFix)
Adds date, leaving time unchanged.

Parameters:
year - years to add
month - months to add
day - days to add
monthFix - true for month fixing, false otherwise
See Also:
add(int, int, int, int, int, double, boolean)

add

public void add(int year,
                int month,
                int day)
Adds date, leaving time unchanged, with preset value of monthFix. attribute.

Parameters:
year - years to add
month - months to add
day - days to add
See Also:
add(int, int, int, boolean)

addTime

public void addTime(int hour,
                    int minute,
                    double second,
                    boolean monthFix)
Adds time.

Parameters:
hour - hours to add
minute - minutes to add
second - seconds to add
monthFix - true for month fixing, false otherwise
See Also:
add(int, int, int, int, int, double)

addTime

public void addTime(int hour,
                    int minute,
                    double second)
Adds time, with preset value of monthFix.

Parameters:
hour - hours to add
minute - minutes to add
second - seconds to add
See Also:
addTime(int, int, double, boolean)

addYear

public void addYear(int y,
                    boolean monthFix)
Adds year.

Parameters:
y - year to add
monthFix - true for month fixing, false otherwise

addYear

public void addYear(int y)
Adds year, with preset value of monthFix.

Parameters:
y - year to add

addMonth

public void addMonth(int m,
                     boolean monthFix)
Adds month.

Parameters:
m - month to add
monthFix - true for month fixing, false otherwise

addMonth

public void addMonth(int m)
Adds month, with preset value of monthFix.

Parameters:
m - month to add

addDay

public void addDay(int d,
                   boolean monthFix)
Adds days.

Parameters:
d - days to add
monthFix - true for month fixing, false otherwise

addDay

public void addDay(int d)
Adds days, with preset value of monthFix.

Parameters:
d - days to add

addHour

public void addHour(int h,
                    boolean monthFix)
Adds hours.

Parameters:
h - hours to add
monthFix - true for month fixing, false otherwise

addHour

public void addHour(int h)
Adds hours, with preset value of monthFix.

Parameters:
h - hours to add

addMinute

public void addMinute(int m,
                      boolean monthFix)
Adds minutes.

Parameters:
m - minutes to add.
monthFix - true for month fixing, false otherwise

addMinute

public void addMinute(int m)
Adds minutes, with preset value of monthFix.

Parameters:
m - minutes to add.

addSecond

public void addSecond(double s,
                      boolean monthFix)
Adds seconds.

Parameters:
s - seconds to add
monthFix - true for month fixing, false otherwise

addSecond

public void addSecond(double s)
Adds seconds, with preset value of monthFix.

Parameters:
s - seconds to add

addMillisecond

public void addMillisecond(int ms,
                           boolean monthFix)
Adds milliseconds.

Parameters:
ms - miliseconds to add
monthFix - true for month fixing, false otherwise

addMillisecond

public void addMillisecond(int ms)
Adds milliseconds, with preset value of monthFix.

Parameters:
ms - miliseconds to add

set

public void set(int year,
                int month,
                int day)
Sets date, time is set to midnight (00:00:00.000).

Parameters:
year - year to set
month - month to set
day - day to set

setTime

public void setTime(int hour,
                    int minute,
                    double second)
Sets time, date is unchanged.

Parameters:
hour - hours to set
minute - minutes to set
second - secnds to set

setDate

public void setDate(int year,
                    int month,
                    int day)
Sets date, time remains unchanged.

Parameters:
year - year
month - month
day - day

set

public void set(long milis)
Sets the time based on current time in milliseconds. Current time is calculated from the midnight, January 1, 1970 UTC.

Parameters:
milis - time in milliseconds, from the midnight, January 1, 1970 UTC

setYear

public void setYear(int y)
Sets current year.

Parameters:
y - year to set

setMonth

public void setMonth(int m)
Sets current month.

Parameters:
m - month to set

setDay

public void setDay(int d)
Sets current day.

Parameters:
d - day to set

setHour

public void setHour(int h)
Set current hour.

Parameters:
h - hour to set

setMinute

public void setMinute(int m)
Set current minute.

Parameters:
m - minutes to set

setSecond

public void setSecond(double s)
Sets current second and millisecond.

Parameters:
s - seconds and milliseconds to set

setSecond

public void setSecond(int s)
Sets current second.

Parameters:
s - seconds to set

setMillisecond

public void setMillisecond(int m)
Sets current millisecond.

Parameters:
m - milliseconds to set

getYear

public int getYear()
Returns current year.

Returns:
current year

getMonth

public int getMonth()
Returns current month.

Returns:
current month

getDay

public int getDay()
Returns current day of month.

Returns:
current day of month
See Also:
getDayOfMonth()

getDayOfMonth

public int getDayOfMonth()
Returns current day of month.

Returns:
current day of month
See Also:
getDay()

getHour

public int getHour()
Returns current hour.

Returns:
current hour

getMinute

public int getMinute()
Returns current minutes.

Returns:
current minutes

getSecond

public double getSecond()
Return current secodns. For an integer value, just cast the returned value.

Returns:
current seconds.

getMillisecond

public int getMillisecond()
Returns current milliseconds.

Returns:
current milliseconds

getDayOfWeek

public int getDayOfWeek()
Returns current day of week.

Returns:
current day of week

getDayOfYear

public int getDayOfYear()
Returns current day of year.

Returns:
current day of year

isLeap

public boolean isLeap()
Returns current leap year flag.

Returns:
current leap year flag

getWeekOfYear

public int getWeekOfYear()
Returns current week of year.

Returns:
current week of year

getWeekOfMonth

public int getWeekOfMonth()

getMonthLength

public int getMonthLength(int m)
Returns the length of the specified month in days.

Returns:
length of the specified month in days

getMonthLength

public int getMonthLength()
Returns the length of the current month in days.

Returns:
length of the current month in days

set

public void set()
Sets current local date and time.


registerDefaults

public static void registerDefaults()
Registers default converters.


register

public static void register(java.lang.Class c,
                            JdtConverter gtc)
Registers a JdtConvertor for a specific class. Convertor knows how to read (extract) data from an object, but also how to populate the same object after it creates a new instance of it.

Because both reading and creating new instance is required by converter, it is not possible to register a superclass and work with its subclasses. Instead, all classes that would be used for the time converters must be registered separately. Example: java.util.Calendar has a subclass java.util.GregorianCalendar. But it is not possible to have just converter for Calendar - there must be converter for GregorianCalendar, too (of course, if it attended to be used).

Parameters:
c - class of an object that will be instanced and populated with time
gtc - converter

loadFrom

public void loadFrom(java.lang.Object o)
Loads time from an object by using registered converters.

Parameters:
o - object to read time from

getInstance

public java.lang.Object getInstance(java.lang.Class c)
Stores time to a new instance of desired class, by using converters.

Parameters:
c - class of new object
Returns:
new instance of specified class, populated with time

getCalendarInstance

public java.util.Calendar getCalendarInstance()
Shortcut for getInstance() that builds and returns Calendar instance.

Returns:
Calendar instance
See Also:
getInstance(java.lang.Class)

getDateInstance

public java.util.Date getDateInstance()
Shortcut for getInstance() that builds and returns Date instance.

Returns:
Date instance
See Also:
getInstance(java.lang.Class)

getGregorianCalendarInstace

public java.util.GregorianCalendar getGregorianCalendarInstace()
Shortcut for getInstance() that builds and returns GregorianCalendar instance.

Returns:
GregorianCalendar instance
See Also:
getInstance(java.lang.Class)

getSqlDateInstace

public java.sql.Date getSqlDateInstace()
Shortcut for getInstance() that builds and returns java.sql.Date instance.

Returns:
java.sql.Date instance
See Also:
getInstance(java.lang.Class)

getSqlTimestampInstance

public java.sql.Timestamp getSqlTimestampInstance()
Shortcut for getInstance() that builds and returns java.sql.Timestamp instance.

Returns:
java.sql.Date instance
See Also:
getInstance(java.lang.Class)

getJDateTimeInstance

public JDateTime getJDateTimeInstance()
Shortcut for getInstance() that builds and returns new JDateTime instance with the date/time set as the original one.

Returns:
new JDateTime instance
See Also:
getInstance(java.lang.Class)

storeTo

public void storeTo(java.lang.Object o)
Stores time to an existing instance of desired class, by using converters.

Parameters:
o - object where to store time info

setTimeStamp

public void setTimeStamp(DateTimeStamp t)
Deprecated. use setDateTimeStamp() instead

Sets the new timestamp.

Parameters:
t -
See Also:
setDateTimeStamp(jodd.datetime.DateTimeStamp)

setDateTimeStamp

public void setDateTimeStamp(DateTimeStamp t)
Sets the new timestamp.

Parameters:
t -

getDateTimeStamp

public DateTimeStamp getDateTimeStamp()
Returns new object generic time stamp.

Returns:
timestamp

setDefaultMonthFix

public static void setDefaultMonthFix(boolean v)
Sets default month fix value.

Parameters:
v - default month fix value

resetDefaultMonthFix

public static void resetDefaultMonthFix()
Resets default month fix value to true.


setMonthFix

public void setMonthFix(boolean v)
Sets month fix value.

Parameters:
v - month fix value

resetMonthFix

public void resetMonthFix()
Resets month fix value to default one.


getMonthFix

public boolean getMonthFix()
Returns actual mont fix value.


setDefaultNames

public static void setDefaultNames(JdtNames newNames)
Sets default JDateTime names.

Parameters:
newNames - names

resetDefaultNames

public static void resetDefaultNames()
Resets default date time names to English.


setNames

public void setNames(JdtNames newNames)
Sets current date time names.

Parameters:
newNames -

resetNames

public void resetNames()
Reset current names to default values.


getNames

public JdtNames getNames()
Returns actual date time names.

Returns:
actual date time names.

setDefaultFormatTemplate

public static void setDefaultFormatTemplate(java.lang.String newFormatTemplate)
Sets default format template.

Parameters:
newFormatTemplate -

resetDefaultFormatTemplate

public static void resetDefaultFormatTemplate()
Resets default format to JDateTime defaults format: YYYY-MM-DD hh:mm:s.m


setFormatTemplate

public void setFormatTemplate(java.lang.String newFormat)
Sets current format template.

Parameters:
newFormat -

resetFormatTemplate

public void resetFormatTemplate()
Resets current format template to default value.


getFormatTemplate

public java.lang.String getFormatTemplate()
Returns actual format template.

Returns:
actual format template

setDefaultFormatter

public static void setDefaultFormatter(JdtFormatter f)
Sets default formatter

Parameters:
f - formatter instance

get

public java.lang.String get(java.lang.String template)
Get current date/time in specified format.

Parameters:
template - format template
Returns:
current date/time string

get

public java.lang.String get()
Get current date/time in default format.

Returns:
current date/time string

set

public void set(java.lang.String s,
                java.lang.String template)
Sets date/time from a string and specified template.

Parameters:
s - string containing date time information
template - format template

set

public void set(java.lang.String s)
Sets date/time from a string and default template.

Parameters:
s - string containing date time information

setDefaultWeekDefinition

public static void setDefaultWeekDefinition(int start,
                                            int must)
Defines default week. Not valid values are ignored and may be used for individual settings of each of 2 input parameters.

Parameters:
start - first day in week
must - must have day of the 1st week

setWeekDefinition

public void setWeekDefinition(int start,
                              int must)
Defines week.

Parameters:
start - first day in week
must - must have day of the 1st week

resetDefaultWeekDefinition

public static void resetDefaultWeekDefinition()
Resets default week definition.


resetWeekDefintion

public void resetWeekDefintion()
Resets week definition.


getFirstDayOfWeek

public int getFirstDayOfWeek()
Returns the first day of the week.

Returns:
first day of week

getMustHaveDayOfFirstWeek

public int getMustHaveDayOfFirstWeek()
Returns must have day of the 1st week.

Returns:
must have day of the first week

getMinimalDaysInFirstWeek

public int getMinimalDaysInFirstWeek()
Returns minimal number of days of the first week. It is calculated from must have day of the first week.

Returns:
minimal number of days of the first week

setDefaultWeekDefinitionAlt

public static void setDefaultWeekDefinitionAlt(int start,
                                               int min)
Defines default week alternatively.

Parameters:
start - first day in week
min - minimal days of week

setWeekDefinitionAlt

public void setWeekDefinitionAlt(int start,
                                 int min)
Defines week alternatively.

Parameters:
start - first day in week
min - minimal days of week

isValid

public static boolean isValid(java.lang.String s)
Checks if some string represents a valid date. It uses JDateTime's default format template.

Parameters:
s - string
Returns:
true if date is valid, otherwise false

isValid

public static boolean isValid(java.lang.String s,
                              java.lang.String template)
Checks if some string represents a valid date.

Parameters:
s - string
template - template
Returns:
true if date is valid, otherwise false

toString

public java.lang.String toString()
Returns date time string in YYYY-MM-DD hh:mm:s.m format.

Returns:
date time string in default format
See Also:
get(java.lang.String)


Jodd v0.24.5 Javadoc