java時間格式的簡單整理
概述
自己在使用Java日志格式的時候,發(fā)現不好定義。所以本篇文章的主要目的是收集一些常用的日志格式,解說每個字段代表的意思以及擴充部分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 |
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
- Java前后端時間格式的轉化方式
- Java SimpleDateFormat中英文時間格式化轉換詳解
- 新手小白學JAVA 日期類Date SimpleDateFormat Calendar(入門)
- java的SimpleDateFormat線程不安全的幾種解決方案
- 解決Java中SimpleDateFormat線程不安全的五種方案
- Java在并發(fā)環(huán)境中SimpleDateFormat多種解決方案
- Java SimpleDateFormat線程安全問題原理詳解
- JAVA使用SimpleDateFormat類表示時間代碼實例
- Java 時間格式轉換之impleDateFormat與Data API解析與使用
相關文章
Java的Struts2框架配合Ext JS處理JSON數據的使用示例
這篇文章主要介紹了Java的Struts2框架配合Ext JS處理JSON數據的使用示例,包括將Ext JS中的JSON數據解析為列表的方法,需要的朋友可以參考下2016-03-03