java時(shí)間格式的簡(jiǎn)單整理
概述
自己在使用Java日志格式的時(shí)候,發(fā)現(xiàn)不好定義。所以本篇文章的主要目的是收集一些常用的日志格式,解說(shuō)每個(gè)字段代表的意思以及擴(kuò)充部分Java常用的時(shí)間類。
名詞解釋
時(shí)刻:時(shí)刻是時(shí)間上的某個(gè)瞬間,,或是時(shí)間軸上的某個(gè)點(diǎn)。時(shí)刻可以作為時(shí)間間隔的起點(diǎn)和終點(diǎn)
時(shí)代:一個(gè)時(shí)代是用作測(cè)量其他時(shí)刻的起源的瞬間。 時(shí)代是在1970-01-01T00:00:00Z。時(shí)代之后的時(shí)刻具有正值,而時(shí)代之前的時(shí)刻具有負(fù)值。
java 8類說(shuō)明
java.time 包含的api都是基于iso 8601的。
1.java.time.LocalDate:LocalDate是一個(gè)不可變的類,它表示默認(rèn)格式(yyyy-MM-dd)的日期
2.java.time.LocalTime:LocalTime是一個(gè)不可變的類,它的實(shí)例代表一個(gè)符合人類可讀格式的時(shí)間,默認(rèn)格式是hh:mm:ss.zzz
ISO字符替代說(shuō)明
[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.
時(shí)間格式收錄
序號(hào) | 格式 | 示例 |
---|---|---|
1 | yyyy/MM/dd HH:mm:ss Z | 2018/05/16 15:09:02 +0800 |
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- Java前后端時(shí)間格式的轉(zhuǎn)化方式
- Java SimpleDateFormat中英文時(shí)間格式化轉(zhuǎn)換詳解
- 新手小白學(xué)JAVA 日期類Date SimpleDateFormat Calendar(入門)
- java的SimpleDateFormat線程不安全的幾種解決方案
- 解決Java中SimpleDateFormat線程不安全的五種方案
- Java在并發(fā)環(huán)境中SimpleDateFormat多種解決方案
- Java SimpleDateFormat線程安全問(wèn)題原理詳解
- JAVA使用SimpleDateFormat類表示時(shí)間代碼實(shí)例
- Java 時(shí)間格式轉(zhuǎn)換之impleDateFormat與Data API解析與使用
相關(guān)文章
詳解Spring Data操作Redis數(shù)據(jù)庫(kù)
Redis是一種NOSQL數(shù)據(jù)庫(kù),Key-Value形式對(duì)數(shù)據(jù)進(jìn)行存儲(chǔ),其中數(shù)據(jù)可以以內(nèi)存形式存在,也可以持久化到文件系統(tǒng)。Spring data對(duì)Redis進(jìn)行了很好的封裝,用起來(lái)也是十分的得心應(yīng)手,接下來(lái)通過(guò)本文給大家分享Spring Data操作Redis數(shù)據(jù)庫(kù),需要的朋友參考下2017-03-03Java布隆過(guò)濾器的應(yīng)用實(shí)例
這篇文章主要介紹了Java布隆過(guò)濾器的應(yīng)用實(shí)例,在程序的世界中,布隆過(guò)濾器是程序員的一把利器,利用它可以快速地解決項(xiàng)目中一些比較棘手的問(wèn)題,如網(wǎng)頁(yè)?URL?去重、垃圾郵件識(shí)別、大集合中重復(fù)元素的判斷和緩存穿透等問(wèn)題,需要的朋友可以參考下2023-11-11Druid簡(jiǎn)單實(shí)現(xiàn)數(shù)據(jù)庫(kù)的增刪改查方式
這篇文章主要介紹了Druid簡(jiǎn)單實(shí)現(xiàn)數(shù)據(jù)庫(kù)的增刪改查方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2024-07-07Java的Struts2框架配合Ext JS處理JSON數(shù)據(jù)的使用示例
這篇文章主要介紹了Java的Struts2框架配合Ext JS處理JSON數(shù)據(jù)的使用示例,包括將Ext JS中的JSON數(shù)據(jù)解析為列表的方法,需要的朋友可以參考下2016-03-03詳解如何使用ModelMapper庫(kù)進(jìn)行對(duì)象之間的屬性映射
這篇文章主要介紹了如何使用ModelMapper庫(kù)進(jìn)行對(duì)象之間的屬性映射實(shí)現(xiàn)詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-07-07Spring?Data?JPA命名約定查詢實(shí)現(xiàn)方法
這篇文章主要為大家介紹了Spring?Data?JPA命名約定查詢實(shí)現(xiàn)方法示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-12-12在logback.xml中自定義動(dòng)態(tài)屬性的方法
這篇文章主要介紹了在logback.xml中自定義動(dòng)態(tài)屬性的方法,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-08-08