当前位置: 移动技术网 > IT编程>开发语言>Java > java时间格式的简单整理

java时间格式的简单整理

2019年07月19日  | 移动技术网IT编程  | 我要评论

概述

自己在使用java日志格式的时候,发现不好定义。所以本篇文章的主要目的是收集一些常用的日志格式,解说每个字段代表的意思以及扩充部分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

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持移动技术网。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网