SimpleDateFormat 类中有哪些可用的日期格式? [英] What are the date formats available in SimpleDateFormat class?

查看:76
本文介绍了SimpleDateFormat 类中有哪些可用的日期格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能告诉我 SimpleDateFormat 类中可用的日期格式.

Can anybody let me know about the date formats available in SimpleDateFormat class.

我已经通过 api 但找不到满意的答案.非常感谢任何帮助.

I have gone through api but could not find a satisfactory answer.Any help is highly appreciated.

推荐答案

下面详细描述了日期和时间格式

Date and time formats are well described below

SimpleDateFormat (Java Platform SE 7) - 日期和时间模式

可能有 n 多种格式.例如 - dd/MM/yyyyYYYY-'W'ww-u 或者您可以混合和匹配字母以实现您所需的模式.图案字母如下.

There could be n Number of formats you can possibly make. ex - dd/MM/yyyy or YYYY-'W'ww-u or you can mix and match the letters to achieve your required pattern. Pattern letters are as follow.

  • G - 纪元 (AD)
  • y - 年份 (1996; 96)
  • Y - 周年 (2009; 09)
  • M - 一年中的月份(七月;七月;07)
  • w - 一年中的一周 (27)
  • W - 月中的周 (2)
  • D - 一年中的第几天 (189)
  • d - 月中的第几天 (10)
  • F - 月中的星期几 (2)
  • E - 星期几(星期二;星期二)
  • u - 星期几(1 = 星期一,...,7 = 星期日)
  • a - AM/PM 标记
  • H - 一天中的小时 (0-23)
  • k - 一天中的小时 (1-24)
  • K - 上午/下午的小时 (0-11)
  • h - 上午/下午的小时数 (1-12)
  • m - 以小时为单位的分钟 (30)
  • s - 分秒 (55)
  • S - 毫秒 (978)
  • z - 一般时区(太平洋标准时间;PST;GMT-08:00)
  • Z - RFC 822 时区 (-0800)
  • X - ISO 8601 时区 (-08; -0800; -08:00)
  • G - Era designator (AD)
  • y - Year (1996; 96)
  • Y - Week Year (2009; 09)
  • M - Month in year (July; Jul; 07)
  • w - Week in year (27)
  • W - Week in month (2)
  • D - Day in year (189)
  • d - Day in month (10)
  • F - Day of week in month (2)
  • E - Day name in week (Tuesday; Tue)
  • u - Day number of week (1 = Monday, ..., 7 = Sunday)
  • a - AM/PM marker
  • H - Hour in day (0-23)
  • k - Hour in day (1-24)
  • K - Hour in am/pm (0-11)
  • h - Hour in am/pm (1-12)
  • m - Minute in hour (30)
  • s - Second in minute (55)
  • S - Millisecond (978)
  • z - General time zone (Pacific Standard Time; PST; GMT-08:00)
  • Z - RFC 822 time zone (-0800)
  • X - ISO 8601 time zone (-08; -0800; -08:00)

解析:

2000-01-23T04:56:07.000+0000

2000-01-23T04:56:07.000+0000

使用:new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");

这篇关于SimpleDateFormat 类中有哪些可用的日期格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆