1 Date Format example:
Public static final string date_format_1 = "m/D/YYYY ";
Public static final string date_format_2 = "mm/DD/YYYY ";
Public static final string date_format_3 = "m/D/YYYY hh: mm: ss ";
Public static final string date_format_4 = "yyyy-mm-dd ";
Public static final string date_format_5 = "eeeee, mmm. dd ";
Public static final string date_format_long = "Mmmmm DD, yyyy eeeee ";
Public static final string date_format_short = "Mmm DD, yyyy eee ";
Public static final string date_format_hour_twenty_four = "mm/DD/YYYY hh: mm: SS ";
Public static final string date_format_hour_twelve = "mm/DD/YYYY hh: mm: ss ";
Public static final string date_format_coupon = "yyyy-mm-dd't'hh: mm: SS ";
// #8601
Public static final string date_format_pv_event = "yyyymmdd. hhmmss. ssszz ";
2. Format a date type
/**
* Format date
*
* @ Param Format
* @ Param date
* @ Return formatted date string
*/
Public static string formatdate (string format, date ){
Return dateformat. Format (format, date). tostring ();
}
3. Format a date string type
/**
*
* @ Param date
* @ Param formatin
* @ Param formatout
* @ Return
*/
Public static string changedateformate (string date, string formatin, string formatout ){
Simpledateformat formats = new simpledateformat (formatin, locale. US );
Simpledateformat outformat = new simpledateformat (formatout, locale. US );
Try {
Date mdate = partition. parse (date );
Return outformat. Format (mdate );
} Catch (parseexception e ){
E. printstacktrace ();
}
Return date;
}