PropertyEventMethodIndex
WebSquare.date - 5.0_4.4547B.20211124.201933

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.
toTimestampString( dateObj )
java

Property Detail

Event Detail

Method Detail

dateAdd( day1 , offset )
Adds the offset to the date. ( date + offset )
Parameter
nametyperequireddescription
day1StringYDate
offsetNumberYOffset to add
Return
typedescription
StringResulting date
Sample
var addDate = WebSquare.date.dateAdd( 20120102, 7 ); addDate : 20120109
dateDiff( day1 , day2 )
Returns the difference between the two dates. ( to - from )
Parameter
nametyperequireddescription
day1StringYStarting date
day2StringYEnding date
Return
typedescription
StringDifference between the two dates
Sample
var 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
nametyperequireddescription
day1StringYDate and time
offsetNumberYOffset to add
typeStringYTarget to add the offset (hour, minute )
Return
typedescription
StringResulting date
Sample
var 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 978
Parameter
nametyperequireddescription
patternStringNDate format (Example: yyyyMMdd )
Return
typedescription
StringServer date (and time) as a string
Sample
var 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
nametyperequireddescription
dateFormatStrStringYDate in string such as "yyyyMMdd"
Return
typedescription
StringDay in string format such as "Monday"
Sample
var 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
nametyperequireddescription
dateObjObjectYJavaScript date object
patternStringN
Return
typedescription
StringDate 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
Sample
var 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
nametyperequireddescription
valueStringYDate to convert
ioFormatStringYioFormat of the date
calendarValueTypeStringNCurrent calendarValueType
Return
typedescription
StringReturns the date in the specified ioFormat.
Sample
The 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
nametyperequireddescription
valueStringYDate to convert
ioFormatStringYCurrent ioFormat
calendarValueTypeStringNCurrent calendarValueType
Return
typedescription
StringReturns the date in the format of "Year" > "Month" > "Day" > "Hour".
Sample
The 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
typedescription
ObjectmaxYear, minYear
Sample
maxYear and minYear in the config.xml are the default. <websquare> <date> <maxYear value="2099" /> <minYear value="1000" /> </date> </websquare> var maxMinYear = WebSquare.date.getMaxMinYear(); maxMinYear[ "maxYear" ] : 2099 (yyyy) maxMinYear[ "minYear" ] : 1000 (yyyy)
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
nametyperequireddescription
objObjectYwebsquare object
sDateStringYDate to verify
Return
typedescription
BooleanIf valid, true, and if not, "false".
Sample
var 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
nametyperequireddescription
strStringYDate string
formatStringNDate format
Return
typedescription
ObjectJavaScript Date object (Parsing result of the date-format data)
Sample
var 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
nametyperequireddescription
solarStringYSolar-calendar date in "yyyyMMdd" format
Return
typedescription
StringLunar-calendar date in string format
Sample
var lunar = WebSquare.date.toLunar("20111225"); lunar : 20111201
toTimestampString( dateObj )
yyyy-mm-dd hh:mm:ss.fffffffff used by java.sql.Timestamp is returned.
Parameter
nametyperequireddescription
dateObjObjectYJavaScript date object
Return
typedescription
StringString in the format of yyyy-mm-dd hh:mm:ss.fffffffff
Sample
var dateObj = new Date(); var dateStr = WebSquare.date.toTimestampString (dateObj); dateStr : 2011-12-25 11:01:47.219000