Provides APIs to manage date and time.
Type
- engine
Property Summary
Event Summary
Method Summary
- dateAdd( day1 , offset )
- Adds as many days as defined to the date. (date + offset)
- dateDiff( day1 , day2 )
- Returns the difference between the two dates. ( to - from )
- dateTimeAdd( day1 , offset , type )
- Adds the offset to the date and time. ( date + offset )
- getCurrentServerDate( pattern )
- Returns the current time of the server.
- getDay( dateFormatStr )
- Receives the date in "yyyyMMdd" format and returns the corresponding day (for example "Monday" string.)
- getFormattedDate( dateObj , pattern )
- Receives a Date object and returns the time in the specified format.
- getIOFormatDate( value , ioFormat , calendarValueType )
- Rreceives the date, ioFormat, and calendarValueType.
- getIOUnFormatDate( value , ioFormat , calendarValueType )
- Receives the date, the ioFormat, and the calendarValueType, and returns the result for the corresponding calendarValueType.
- getMaxMinYear( )
- Returns an object that contains maxYear and minYear.
- isValidDate( obj , sDate )
- Verifies if the date received in "yyyyMMdd" format is valid, and returns the result in boolean.
- parseDate( str , format )
- Parses the date format and returns the corresponding date.
- toLunar( solar )
- Receives a solar-calendar date in "yyyyMMdd" format and converts it into the corresponding lunar-calendar date in string format.
Property Detail
Event Detail
Method Detail
- dateAdd( day1 , offset )
-
Adds the offset to the date. ( date + offset )
Parameter name type required description day1 String Y Date offset Number Y Offset to add Return type description String Resulting date Samplevar addDate = WebSquare.date.dateAdd( 20120102, 7 ); addDate : 20120109 - dateDiff( day1 , day2 )
-
Returns the difference between the two dates. ( to - from )
Parameter name type required description day1 String Y Starting date day2 String Y Ending date Return type description String Difference between the two dates Samplevar diff = WebSquare.date.dateDiff( "20120120", "20120210" ); diff : 21 - dateTimeAdd( day1 , offset , type )
-
Adds the offset to the date and time. ( date + offset )
Depends on the (day, month, hour, minute, time).
The result may differ.Parameter name type required description day1 String Y Date and time offset Number Y Offset to add type String Y Target to add the offset (hour, minute ) Return type description String Resulting date Samplevar addTimeDate = WebSquare.date.dateTimeAdd( 20120102, 7 ); addDate : 20120109 - getCurrentServerDate( pattern )
-
Returns the current time of the server.
Receives the Java SimpleDateFormat pattern as the parameter to display the time.
In case the pattern is not specified, the date will be displayed in yyyMMdd format.
y Year 1996; 96
M Month in year 07
d Day in month 10
H Hour in day (0-23) 0
m Minute in hour 30
s Second in minute 55
S Millisecond 978Parameter name type required description pattern String N Date format (Example: yyyyMMdd ) Return type description String Server date (and time) as a string Samplevar dateStr = WebSquare.date.getCurrentServerDate(); dateStr : 20111225 (yyyyMMdd) var dateStr = WebSquare.date.getCurrentServerDate("yyyyMMddHHmmssSSS") dateStr : 20111225112433707 (yyyyMMddHHmmssSSS) - getDay( dateFormatStr )
-
Receives the date in "yyyyMMdd" format and returns the corresponding day (for example "Monday" string.)
Parameter name type required description dateFormatStr String Y Date in string such as "yyyyMMdd" Return type description String Day in string format such as "Monday" Samplevar day = WebSquare.date.getDay("20111225"); day : Sunday - getFormattedDate( dateObj , pattern )
-
Receives a Date object and returns the time in the specified format.
In case the pattern is not specified, System.currentTimeMillis() will return the result.Parameter name type required description dateObj Object Y JavaScript date object pattern String N Return type description String Date and time data in the specified format
Letter Date or Time Component Examples y Year 1996; 96 M Month in year 07 d Day in month 10 H Hour in day (0-23) 0 m Minute in hour 30 s Second in minute 55 S Millisecond 978 Samplevar dateObj = new Date(); var dateStr = WebSquare.date.getFormattedDate ( dateObj, “yyyy.MM” ); dateStr : 2011.12 - getIOFormatDate( value , ioFormat , calendarValueType )
-
Rreceives the date, ioFormat, and calendarValueType.
Returns the date in the specified ioFormat.
Related properties include useYearMonthFormat of the InputCalendar.Parameter name type required description value String Y Date to convert ioFormat String Y ioFormat of the date calendarValueType String N Current calendarValueType Return type description String Returns the date in the specified ioFormat. SampleThe following is added to the InputCalendar. Execute getIOFormatDate. Then, the date will be returned in the specified ioFormat. ioFormat = "MMyyyy" calendarValueType = "yearMonth" var ioFormatDate = WebSquare.date.getIOFormatDate ( "201701", "MMyyyy", “yearMonth” ); ioFormatDate : 012017 - getIOUnFormatDate( value , ioFormat , calendarValueType )
-
Receives the date, the ioFormat, and the calendarValueType, and returns the result for the corresponding calendarValueType.
Converts the ioFormat into the format of "Year" > "Monty" > "Day" > "Hour". The related property is the useMonthYearFormat of the InputCalendar.Parameter name type required description value String Y Date to convert ioFormat String Y Current ioFormat calendarValueType String N Current calendarValueType Return type description String Returns the date in the format of "Year" > "Month" > "Day" > "Hour". SampleThe following is added to the InputCalendar. Execute getIOUnFormatDate. Then, the date will be returned in Year - Month - Day - Hour format. ioFormat = "MMyyyy" calendarValueType = "yearMonth" var ioFormatDate = WebSquare.date.getIOFormatDate ( "012017", "MMyyyy", “yearMonth” ); ioFormatDate : 201701 - getMaxMinYear( )
-
Returns an object that contains maxYear and minYear properties. Settings in config.xml is the default as shown below.
Return type description Object maxYear, minYear SamplemaxYear and minYear in the config.xml are the default. - isValidDate( obj , sDate )
-
Verifies if the date received in "yyyyMMdd" format is valid, and returns the result in Boolean. If not valid, the object will be focused.
Parameter name type required description obj Object Y websquare object sDate String Y Date to verify Return type description Boolean If valid, true, and if not, "false". Samplevar validYn = WebSquare.date.isValidDate (input1, input1.getValue()); validYn : input1.getValue() If valid, true, and if not valid, false. - parseDate( str , format )
-
Parses the date format and returns the corresponding date. (Default format: yyyyMMdd)
Parameter name type required description str String Y Date string format String N Date format Return type description Object JavaScript Date object (Parsing result of the date-format data) Samplevar dateObj = WebSquare.date.parseDate ("20120101"); alert(dateObj.toString()); Result : Sun Jan 1 00:00:00 UTC+0900 2012 var dateObj = WebSquare.date.parseDate ("01222013112430", "MMddyyyyHHmmss"); alert(dateObj.toString()); Result : Tue Jan 22 2013 11:24:30 GMT+0900 (KST) - toLunar( solar )
-
Receives a solar-calendar date in "yyyyMMdd" format and converts it into the corresponding lunar-calendar date in string format.
Parameter name type required description solar String Y Solar-calendar date in "yyyyMMdd" format Return type description String Lunar-calendar date in string format Samplevar lunar = WebSquare.date.toLunar("20111225"); lunar : 20111201 - toTimestampString( dateObj )
-
yyyy-mm-dd hh:mm:ss.fffffffff used by java.sql.Timestamp is returned.
Parameter name type required description dateObj Object Y JavaScript date object Return type description String String in the format of yyyy-mm-dd hh:mm:ss.fffffffff Samplevar dateObj = new Date(); var dateStr = WebSquare.date.toTimestampString (dateObj); dateStr : 2011-12-25 11:01:47.219000