telosys.objects
Class SimpleDate

java.lang.Object
  extended bytelosys.objects.SimpleDate

public class SimpleDate
extends java.lang.Object

Simple date utility object for date management. Used by field checking functions ( see fwkCheckAndFormatDate ) The date formats are not case sensitive, any separators can be used ( '/', '-', '.', etc... ) Examples : "DDMMYY", "YY-MM-DD", "YYYY.DD.MM", "DD/MM/YY", "dd/MM/yyyy"


Constructor Summary
SimpleDate(string sDate)
          Creates a new date object using the given date value and the default format "YYYY-MM-DD" ( ISO format )
SimpleDate(string sDate, string sFormat)
          Creates a new date object using the given date value and the given format
 
Method Summary
 string format()
          Formats the current date with the current format
 string format(string sFormat)
          Formats the current date with the given format
 number getDay()
          Returns the day ( 1 to 31 )
 string getFormat()
          Returns the current format
 number getMonth()
          Returns the month ( 1 to 12 )
 number getYear()
          Returns the year ( 0 to N )
 boolean isNull()
          Returns true if the current date is null, else false
 void setDate(string sDate)
          Try to set the new date value according with the current format.
 void setFormat(string sFormat)
          Sets the new date format
 void show()
          Shows the date description and current values ( with an 'alert box' ).
 string toString_()
          Returns the date current values ( day, month, year and format )
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleDate

public SimpleDate(string sDate)
           throws java.lang.Exception
Creates a new date object using the given date value and the default format "YYYY-MM-DD" ( ISO format )

Parameters:
sDate - : the date value (according with the ISO format) or null
Throws:
java.lang.Exception - if the given date is invalid

SimpleDate

public SimpleDate(string sDate,
                  string sFormat)
           throws java.lang.Exception
Creates a new date object using the given date value and the given format

Parameters:
sDate - : the date value (according with the given format) or null
sFormat - : e.g. "" ( not case sensitive )
Throws:
java.lang.Exception - if the given date or format is invalid
Method Detail

toString_

public string toString_()
Returns the date current values ( day, month, year and format )

Returns:
the complete date

show

public void show()
Shows the date description and current values ( with an 'alert box' ). For debug only


format

public string format()
Formats the current date with the current format

Returns:
the formatted date or null if the current value is null

format

public string format(string sFormat)
              throws java.lang.Exception
Formats the current date with the given format

Parameters:
sFormat - : the format to apply ( not case sensitive )
Returns:
the formatted date or null if the current value is null
Throws:
java.lang.Exception - if the given format is invalid

isNull

public boolean isNull()
Returns true if the current date is null, else false

Returns:
true(null) | false(not null)

getDay

public number getDay()
Returns the day ( 1 to 31 )

Returns:
the day ( or 0 if the current date is null )

getMonth

public number getMonth()
Returns the month ( 1 to 12 )

Returns:
the month ( or 0 if the current date is null )

getYear

public number getYear()
Returns the year ( 0 to N )

Returns:
the year ( or 0 if the current date is null )

getFormat

public string getFormat()
Returns the current format

Returns:
the format

setFormat

public void setFormat(string sFormat)
               throws java.lang.Exception
Sets the new date format

Parameters:
sFormat - the new format
Throws:
java.lang.Exception - if the given format is invalid

setDate

public void setDate(string sDate)
             throws java.lang.Exception
Try to set the new date value according with the current format. The current format is only used to know the order of the date parts ( DD, MM, YY ). The new date value can have a separator different from original format ( . - / ) or no separator.

Parameters:
sDate - : the new date ( "311208", "31-12-08", "31.12.2008", etc...) to set or null
Throws:
java.lang.Exception - if the given date is invalid