本文目錄一覽:
java怎麼獲取19位時間戳
public Long getToday(){
DateTime now = new DateTime();
return new DateTime(now.getYear(), now.getMonthOfYear(), now.getDayOfMonth(), 0, 0, 0, 0).getMillis();
}
public Long getTomorrow(){
DateTime now = new DateTime();
return new DateTime(now.getYear(), now.getMonthOfYear(), now.getDayOfMonth(), 0, 0, 0, 0).plusDays(1).getMillis();
}
java中14位時間戳怎麼獲取
按你描述,應該想要的是Unix時間戳,即當前時間到1970年1月1日0:0:0的毫秒數據。
在java裏面Data類型可以直接用API獲取。
SimpleDateFormat df = new SimpleDateFormat(“yyyy-MM-dd hh:mm:ss”)
String value=20150704000000;
df.parse(value).getTime(); 就是你想要的時間戳。
具體可以查看Date類型的API
以及
Java獲取時間戳精確到年月日時
其實系統默認的都是毫秒數的時間戳, 所以你想要的2017-01-16 17:00:00 不是提取的, 而是格式化的
new SimpleDateFormat(“yyyy-MM-dd HH:00:00”).format(System.currentTimeMillis());
原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-hk/n/252848.html