Java日期转换SimpleDateFormat格式大全
来源:互联网 发布:淘宝上的多少人付款 编辑:程序博客网 时间:2024/05/21 11:22
24小时制时间显示:
publicclass Datetime{
public staticvoid main(String args[]){
java.util.Datecurrent=newjava.util.Date();
java.text.SimpleDateFormat sdf=newjava.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String c=sdf.format(current);
System.out.println(c);
}
}
12小时制时间显示:
public class Datetime {
public staticvoid main(String args[]){
java.util.Datecurrent=newjava.util.Date();
java.text.SimpleDateFormat sdf=newjava.text.SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
String c=sdf.format(current);
System.out.println(c);
}
}
两者区别:yyyy-MM-dd HH:mm:ss ; yyyy-MM-dd hh:mm:ss
如下:
G
Era 标志符TextAD
y
年Year1996
; 96
M
年中的月份MonthJuly
; Jul
;07
w
年中的周数Number27
W
月份中的周数Number2
D
年中的天数Number189
d
月份中的天数Number10
F
月份中的星期Number2
E
星期中的天数TextTuesday
; Tue
a
Am/pm 标记TextPM
H
一天中的小时数(0-23)Number0
k
一天中的小时数(1-24)Number24
K
am/pm 中的小时数(0-11)Number0
h
am/pm 中的小时数(1-12)Number12
m
小时中的分钟数Number30
s
分钟中的秒数Number55
S
毫秒数Number978
z
时区General time zonePacific Standard Time
; PST
; GMT-08:00
Z
时区RFC 822 time zone-0800
参考:http://java.chinaitlab.com/base/747297.html
0 0
- Java日期转换SimpleDateFormat格式大全
- Java日期转换SimpleDateFormat格式大全
- Java日期转换SimpleDateFormat格式大全
- Java日期转换SimpleDateFormat格式大全
- Java日期转换SimpleDateFormat格式大全
- Java日期转换SimpleDateFormat格式大全
- Java日期转换SimpleDateFormat格式大全
- Java日期转换SimpleDateFormat格式大全
- Java日期转换SimpleDateFormat格式大全
- Java日期转换SimpleDateFormat格式大全
- Java日期转换SimpleDateFormat格式大全
- Java日期转换SimpleDateFormat格式大全
- java日期格式大全 format SimpleDateFormat
- java日期格式大全 format SimpleDateFormat
- java日期格式大全 format SimpleDateFormat
- java日期格式大全 format SimpleDateFormat
- java日期格式大全 format SimpleDateFormat
- java日期格式大全 format SimpleDateFormat
- 初识.NET —— 总结很重要
- java 图片上传
- LeetCode :: Reverse Words in a String
- MySQL源码分析及核心内幕之1 -- 源码目录结构
- 安卓屏幕代码适配屏幕心得px和dp;sp和dp选择
- Java日期转换SimpleDateFormat格式大全
- 高速总线标准
- cocoapods安装中一种错误的解决方案
- 函数重载的问题
- MySQL源码分析及核心内幕之2 -- 源码调试之gdb
- ffmpeg 音视频合成分割
- 算法的时间和空间复杂度
- 八圆包,小而美九块九包邮集市的一枚新锐
- cocos2d 最后一堂课