常見時間日期格式與字串之間的轉換

2021-10-06 20:39:12 字數 2258 閱讀 6466

/

public class timeformat

/**

* yyyymmddhhmmss

* * @param date

* @return

*/public static string datetostring(date date)

/** * yyyy-mm-dd hh:mm:ss

* * @param date

* @return

*/public static string datetostring2(date date)

/** * yyyy年mm月dd日 hh點mm分ss秒

* * @param date

* @return

*/public static string datetostring3(date date)

/** * yyyy年mm月dd日 星期一 hh點mm分ss秒

* * @param date

* @return

*/public static string datetostring4(date date)

/** * yyyy/mm/dd hh:mm:ss

* * @param date

* @return

*/public static string datetostring5(date date)

/** * yyyy-mm-dd

* * @param date

* @return

*/public static string datetostring6(date date)

/** * yyyy/mm/dd

* * @param date

* @return

*/public static string datetostring7(date date)

/** * yyyy年mm月dd日

* * @param date

* @return

*/public static string datetostring8(date date)

/** * yyyymmdd

* * @param date

* @return

*/public static string datetostring9(date date)

/** * yyyy-mm-dd轉yyyy/mm/dd

* * @param str

* @return

*/public static string strdatetostring(string str)

/** * yyyy/mm/dd轉yyyy-mm-dd

* * @param str

* @return

*/public static string strdatetostring2(string str)

/** * yyyy/mm/dd轉yyyy年mm月dd日

* * @param str

* @return

*/public static string strdatetostring3(string str)

/** * yyyy年mm月dd日轉yyyy/mm/dd

* * @param str

* @return

*/public static string strdatetostring4(string str)

/** * yyyy-mm-dd轉yyyy年mm月dd日

* * @param str

* @return

*/public static string strdatetostring5(string str)

/** * yyyy年mm月dd日轉yyyy-mm-dd

* * @param str

* @return

*/public static string strdatetostring6(string str)

public static string ymdhmse(date date)

case "星期二":

case "星期三":

case "星期四":

case "星期五":

case "星期六":

default:

} return currsun + e;

}public static void main(string args)

根據時間日期格式從字串中解析日期時間

根據時間日期格式從字串中解析日期時間 function strtodtfmt const s,fmt string dft tdatetime tdatetime function strtodtfmt const s,fmt string dft tdatetime tdatetime varpt...

日期與時間字串的格式化

1.日期格式化 date date new date 建立乙個date物件 string s string.format te date 通過format 方法對date進行格式化 s的值,返回當前日期中的天數,te 是轉換符。常用日期格式的轉換符如下 te 乙個月中的某天 1 31 tb 指定語言...

小程式中的時間日期 與 字串的轉化

普通的程式編輯裡,比較重要的乙個小細節處理就是 字串與時間日期的處理。記錄一下筆記。留待大家和自己學習使用。1.時間 轉字串 var mydate new date mydate.tolocaledatestring 可以獲取當前日期 mydate.tolocaletimestring 可以獲取當前...