時間型別轉換

2021-06-19 02:24:44 字數 406 閱讀 6592

日誌檔案中有好多時間型別,可以使用******dateformat物件來進行處理,具體處理步驟如下。

string str = "2013-11-03 15:59:59";

******dateformat sdf = new ******dateformat("yyyy-mm-dd hh:mm:ss");

date date = sdf.parse(str);

以上步驟可以將日期轉換成date型別。

但是有的時候,時間格式為2013-11-03t15:59:59,這裡邊的t無特殊意義,如果還用上述辦法就轉換不了了,可以改為******dateformat sdf = new ******dateformat("yyyy-mm-dd't'hh:mm:ss");進行轉換。

時間型別轉換

最常用的方法 設定日期格式 dateformat df new dateformat yyyy mm dd hh mm ss date轉字串 string date df.format new date new date 為獲取當前系統時間 字串轉date date date df.parse 20...

golang時間型別轉換

1.獲取當前時間,返回utc時間currenttime time.now fmt.printf v t n currenttime,currenttime 2.獲取當前時間戳timeunix time.now unix 單位秒 fmt.printf v t n timeunix,timeunix t...

python時間型別轉換

python中時間 日期 時間戳的轉換 1.簡介 在編寫 時,往往涉及時間 日期 時間戳的相互轉換。2.示例 引入模組 import time,datetime 2.1 str型別的日期轉換為時間戳 1 字元型別的時間 2 tss1 2013 10 10 23 40 00 3 轉為時間陣列 4 ti...