java時間格式的簡單整理
概述
自己在使用Java日志格式的時候,發(fā)現(xiàn)不好定義。所以本篇文章的主要目的是收集一些常用的日志格式,解說每個字段代表的意思以及擴充部分Java常用的時間類。
名詞解釋
時刻:時刻是時間上的某個瞬間,,或是時間軸上的某個點。時刻可以作為時間間隔的起點和終點
時代:一個時代是用作測量其他時刻的起源的瞬間。 時代是在1970-01-01T00:00:00Z。時代之后的時刻具有正值,而時代之前的時刻具有負值。
java 8類說明
java.time 包含的api都是基于iso 8601的。
1.java.time.LocalDate:LocalDate是一個不可變的類,它表示默認格式(yyyy-MM-dd)的日期
2.java.time.LocalTime:LocalTime是一個不可變的類,它的實例代表一個符合人類可讀格式的時間,默認格式是hh:mm:ss.zzz
ISO字符替代說明
[Y] represents a digit used in the time element “year”;
[M] represents a digit used in the time element “month”;
[D] represents a digit used in the time element “day”;
[w] represents a digit used in the time element “week”;
[h] represents a digit used in the time element “hour”;
[m] represents a digit used in the time element “minute”;
[s] represents a digit used in the time element “second”;
[n] represents a digit from a positive integer or zero;
[±] represents a plus sign [+] if in combination with the following element a positive value or zero needs to be represented (in this case, unless explicitly stated otherwise, the plus sign shall not be omitted), or a minus sign [−] if in combination with the following element a negative value needs to be represented.
In addition the following convention applies:
[_] When any of the characters representing a digit is underlined, it represents zero or more digits
in the corresponding date and time representation.
Other characters in the date and time format representations are copied in the date and time
representations.
時間格式收錄
序號 | 格式 | 示例 |
---|---|---|
1 | yyyy/MM/dd HH:mm:ss Z | 2018/05/16 15:09:02 +0800 |
以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
- Java前后端時間格式的轉(zhuǎn)化方式
- Java SimpleDateFormat中英文時間格式化轉(zhuǎn)換詳解
- 新手小白學JAVA 日期類Date SimpleDateFormat Calendar(入門)
- java的SimpleDateFormat線程不安全的幾種解決方案
- 解決Java中SimpleDateFormat線程不安全的五種方案
- Java在并發(fā)環(huán)境中SimpleDateFormat多種解決方案
- Java SimpleDateFormat線程安全問題原理詳解
- JAVA使用SimpleDateFormat類表示時間代碼實例
- Java 時間格式轉(zhuǎn)換之impleDateFormat與Data API解析與使用
相關(guān)文章
詳解Spring Data操作Redis數(shù)據(jù)庫
Redis是一種NOSQL數(shù)據(jù)庫,Key-Value形式對數(shù)據(jù)進行存儲,其中數(shù)據(jù)可以以內(nèi)存形式存在,也可以持久化到文件系統(tǒng)。Spring data對Redis進行了很好的封裝,用起來也是十分的得心應手,接下來通過本文給大家分享Spring Data操作Redis數(shù)據(jù)庫,需要的朋友參考下2017-03-03Druid簡單實現(xiàn)數(shù)據(jù)庫的增刪改查方式
這篇文章主要介紹了Druid簡單實現(xiàn)數(shù)據(jù)庫的增刪改查方式,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2024-07-07Java的Struts2框架配合Ext JS處理JSON數(shù)據(jù)的使用示例
這篇文章主要介紹了Java的Struts2框架配合Ext JS處理JSON數(shù)據(jù)的使用示例,包括將Ext JS中的JSON數(shù)據(jù)解析為列表的方法,需要的朋友可以參考下2016-03-03Spring?Data?JPA命名約定查詢實現(xiàn)方法
這篇文章主要為大家介紹了Spring?Data?JPA命名約定查詢實現(xiàn)方法示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2023-12-12