As time control class. If you are interested, you can use it for expansion. In fact, there are still few functions.
Package COM. shine. framework. util <br/> {<br/> public class dateutil <br/> {<br/> Public Function dateutil () <br/>{< br/>}< br/>/** <br/> * obtaining time example: fri Jul 23 2010 04:50:37 <br/> * If date = NULL, the current time is obtained. <br/> **/<br/> Public static function gettime (date: date = NULL): String <br/>{< br/> If (date = NULL) <br/>{< br/> date = new date (); <br/>}< br/> return date. tolocalestring (); <br/>}< br/>/** <br/> * Date obtained <br/> * If date = NULL, the current time is obtained. <br/> **/<br/> Public static function getdate (date: Date = NULL ): string <br/>{< br/> If (date = NULL) <br/>{< br/> date = new date (); <br/>}< br/> return string (date. getdate ()); <br/>}< br/>/** <br/> * obtain the day of the week. <br/> * If date = NULL, the current time is obtained. <br/> * */<br/> Public static function getday (date: date = NULL): String <br/>{< br/> If (date = NULL) <br/>{< br/> date = new date (); <br/ >}< Br/> return string (date. getday ()); <br/>}< br/>/** <br/> * obtain the month. <br/> * If date = NULL, the current time is obtained. <br/> **/ <br/> Public static function getmonth (date: date = NULL): String <br/>{< br/> If (date = NULL) <br/>{< br/> date = new date (); <br/>}< br/> return string (date. getmonth ()); <br/>}< br/>/** <br/> * obtain the year <br/> * If date = NULL, the current time is obtained. <br/> **/ <br/> Public static function getyear (date: date = NULL): String <br />{< Br/> If (date = NULL) <br/>{< br/> date = new date (); <br/>}< br/> return string (date. getyear ()); <br/>}< br/>/** <br/> * obtain data in full format and output the given date in yyyymmddhhmmss format <br/> * If date = NULL, the data is obtained. current time <br/> **/<br/> Public static function getfulldatastringdata (date: date = NULL): String <br/>{< br/> If (date = NULL) <br/>{< br/> date = new date (); <br/>}< br/> return date. fullyear. tostring () + (date. month + 1 <10? "0": "") + (date. Month + 1) + (date. Date <10? "0": "") + date. Date + (date. Hours <10? "0": "") + date. Hours + (date. Minutes <10? "0": "") + date. minutes + (date. Seconds <10? "0": "") + date. seconds; <br/>}< br/>/** <br/> * Get the full format data and output the given date to the YYYY-MM-DD hh: mm: SS format <br/> * If date = NULL, the current time is obtained. <br/> **/<br/> Public static function getfullserverdatastringdata (date: Date = NULL ): string <br/>{< br/> If (date = NULL) <br/>{< br/> date = new date (); <br/>}< br/> return date. fullyear. tostring () + "-" + (date. month + 1 <10? "0": "") + (date. Month + 1) + "-" + (date. Date <10? "0": "") + date. Date + "+ (date. Hours <10? "0": "") + date. Hours + ":" + (date. Minutes <10? "0": "") + date. minutes + ":" + (date. Seconds <10? "0": "") + date. seconds; <br/>}< br/>/** <br/> * obtain the data in the year, month, and day formats and output the given date to the yyyymmdd format. <br/> * If date = NULL, the data is obtained. current time <br/> **/<br/> Public static function getfullymdstringdata (date: date = NULL): String <br/>{< br/> If (date = NULL) <br/>{< br/> date = new date (); <br/>}< br/> return date. fullyear. tostring () + (date. month + 1 <10? "0": "") + (date. Month + 1) + (date. Date <10? "0": "") + date. date; <br/>}< br/>/** <br/> * obtain year, month, and day format data and output the given date to the YYYY-MM-DD format <br/> * If date = NULL is obtained current time <br/> **/<br/> Public static function getfullserverymdstringdata (date: date = NULL): String <br/>{< br/> If (date = NULL) <br/>{< br/> date = new date (); <br/>}< br/> return date. fullyear. tostring () + "-" + (date. month + 1 <10? "0": "") + (date. Month + 1) + "-" + (date. Date <10? "0": "") + date. date; <br/>}< br/>/** <br/> * obtain the data in the hour, minute, and second format and output the given date to the hhmmss format. <br/> * If date = NULL, the data is obtained. current time <br/> **/<br/> Public static function getfullhmsstringdata (date: date = NULL): String <br/>{< br/> If (date = NULL) <br/>{< br/> date = new date (); <br/>}< br/> return (date. hours <10? "0": "") + date. Hours + (date. Minutes <10? "0": "") + date. minutes + (date. Seconds <10? "0": "") + date. seconds; <br/>}< br/>/** <br/> * obtain the data in the hour, minute, and second format and output the given date to the hhmmss format. <br/> * If date = NULL, the data is obtained. current time <br/> **/<br/> Public static function getfullserverhmsstringdata (date: date = NULL): String <br/>{< br/> If (date = NULL) <br/>{< br/> date = new date (); <br/>}< br/> return (date. hours <10? "0": "") + date. Hours + ":" + (date. Minutes <10? "0": "") + date. minutes + ":" + (date. Seconds <10? "0": "") + date. seconds; <br/>}< br/>/** <br/> * obtain the time before or after a certain time period <br/> * If date = NULL <br/> **/<br/> Public static function dateadd (datepart: string = "", number: Number = 0, Date: Date = NULL): date <br/>{< br/> If (date = NULL) <br/>{< br/> date = new date (); <br/>}< br/> var returndate: Date = new date (date. time); <br/> switch (datepart. tolowercase () <br/>{< br/> case "fullyear": <br/> case "month": <br/> case "date ": <br/> case "hours": <br/> case "Minutes": <br/> case "seconds": <br/> case "milliseconds ": <br/> returndate [datepart] + = number; <br/> break; <br/> default: <br/>/* unknown date part, do nothing. */<br/> break; <br/>}< br/> return returndate; <br/>}< br/>}