日期格式化参数

不同编程语言的格式化参数不一样!!!

Java SimpleDateFormat格式化参数

字母 日期或时间元素 表示 示例
G Era 标志符 Text AD
y Year 1996; 96
M 年中的月份 Month July; Jul; 07
w 年中的周数 Number 27
W 月份中的周数 Number 2
D 年中的天数 Number 189
d 月份中的天数 Number 10
F 月份中的星期 Number 2
E 星期中的天数 Text Tuesday; Tue
a Am/pm 标记 Text PM
H 一天中的小时数(0-23) Number 0
k 一天中的小时数(1-24) Number 24
K am/pm 中的小时数(0-11) Number 0
h am/pm 中的小时数(1-12) Number 12
m 小时中的分钟数 Number 30
s 分钟中的秒数 Number 55
S 毫秒数 Number 978
z 时区 General time zone Pacific Standard Time; PST; GMT-08:00
Z 时区 RFC 822 time zone -800

Python datetime.datetime.strptime()格式化参数

%a Abbreviated weekday name  本地简化星期名称
%A Full weekday name  本地完整星期名称
%b Abbreviated month name  本地简化的月份名称
%B Full month name  本地完整的月份名称
%c Date and time representation appropriate for locale  本地相应的日期表示和时间表示
%d Day of month as decimal number (01 - 31)  月内中的一天(0-31)
%H Hour in 24-hour format (00 - 23) 24 小时制小时数(0-23)
%I Hour in 12-hour format (01 - 12) 12 小时制小时数(01-12)
%j Day of year as decimal number (001 - 366) 年内的一天(001-366)
%m Month as decimal number (01 - 12) 月份(01-12)
%M Minute as decimal number (00 - 59) 分钟数(00=59)
%p Current locale's A.M./P.M. indicator for 12-hour clock  本地 A.M. 或 P.M. 的等价符
%S Second as decimal number (00 - 59) 秒(00-59)
%U Week of year as decimal number, with Sunday as first day of week (00 - 51) 一年中的星期数(00-53)星期天为星期的开始
%w Weekday as decimal number (0 - 6; Sunday is 0) 星期(0-6),星期天为星期的开始
%W Week of year as decimal number, with Monday as first day of week (00 - 51) 一年中的星期数(00-53)星期一为星期的开始
%x Date representation for current locale  本地相应的日期表示
%X Time representation for current locale  本地相应的时间表示
%y Year without century, as decimal number (00 - 9 9)  两位数的年份表示(00-99)
%Y Year with century, as decimal number  四位数的年份表示(000-9999)
%z %Z Time-zone name or abbreviation; no characters if time zone is unknown  当前时区的名称
%% Percent sign  % 号本身

ISO 8601 国际标准化组织的日期和时间的表示方法

年  Y 公元前加-
月  M
日 D
星期 w
时  hh  00到24
分  m
秒 s
毫秒 sss
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值