日期和时间格式化实用程序和常量
public static String format(Calendar calendar, String pattern)

说明:将日历格式化为特定的模式;
参数:calendar-格式化的日历对象,非null;pattern-用于格式化日历的模式,非null;
返回值:格式化日历;
1
2
3
Calendar cal = Calendar.getInstance();
System.out.println(DateFormatUtils.format(cal, "yyyy-MM-dd HH:mm:ss"));

输出结果:2018-01-23 19:50:55
1
2
3
4
5
public static String format(Calendar calendar, String pattern,TimeZone timeZone)

说明:将日历格式化为特定的模式;
参数:calendar-格式化的日历对象,非null;pattern-用于格式化日历的模式,非null;timeZone-时区
返回值:格式化日历;
1
2
3
Calendar cal = Calendar.getInstance();
System.out.println(DateFormatUtils.format(cal, "yyyy-MM-dd HH:mm:ss", TimeZone.getDefault()));
1
2
public static String format(Calendar calendar, String pattern, Locale locale)

说明:将日历格式化为特定的模式;
参数:calendar-格式化的日历对象,非null;pattern-用于格式化日历的模式,非null;locale-本地化
返回值:格式化日历;
1
2
3
Calendar cal = Calendar.getInstance();
System.out.println(DateFormatUtils.format(cal, "yyyy-MM-dd HH:mm:ss", Locale.CHINA));
1
2
public static String format(Calendar calendar,String pattern,TimeZone timeZone,Locale locale)

说明:格式化日期时指定时区和本地化参数;
1
public static String format(Date date, String pattern)

说明:将日期格式化为特定的模式;
参数:date-格式化的日期对象,非null;pattern-用于格式化日期的模式,非null;
返回值:格式化日期;
1
2
3
Date date = new Date();
System.out.println(DateFormatUtils.format(date, "yyyy-MM-dd HH:mm:ss"));
1
2
public static String format(Date date,String pattern,TimeZone timeZone)

说明:将日期格式化为特定的模式;
参数:date-格式化的日期对象,非null;pattern-用于格式化日期的模式,非null;timeZone-时区
返回值:格式化日期;
1
2
3
Date date = new Date();
System.out.println(DateFormatUtils.format(date, "yyyy-MM-dd HH:mm:ss", TimeZone.getDefault()));
1
2
public static String format(Date date, String pattern, Locale locale)

说明:将日期格式化为特定的模式;
参数:date-格式化的日期对象,非null;pattern-用于格式化日期的模式,非null;locale-本地化参数
返回值:格式化日期;
1
2
3
public static String format(Calendar calendar,String pattern,TimeZone timeZone,Locale locale)

说明:格式化日期时指定时区和本地化参数;
1
public static String format(long millis,String pattern)

说明:将日期/时间格式化为特定的模式;
参数:mills-以毫秒表示格式的日期;pattern-格式化的模式;
1
2
public static String formatUTC(Date date,String pattern)

说明:使用UTC时区将日期/时间格式化为特定的模式;
参数:date-要格式化的时间;pattern-格式化的模式;
返回值:格式化的日期;
---------------------
作者:随风yy
来源:CSDN
原文:https://blog.csdn.net/yaomingyang/article/details/79143954
版权声明:本文为博主原创文章,转载请附上博文链接!

最新文章

  1. python操作mysql总结
  2. A little bit about Handlers in JAX-WS
  3. Maya 脚本控制物体自转
  4. Gson将参数放入实体类中进行包装之后再传递
  5. Larave 多图片上传
  6. C++多态性与C#的比较
  7. Dreamweaver 添加 cakephp ctp后缀名
  8. python调用smtplib模块发送邮件
  9. Sqlserver 正则替换函数的一种实现
  10. ASP.NET MVC 4.0的Action Filter
  11. Houdini Pyro流体的插值变速
  12. java的property
  13. js中的字符替换
  14. js with用法
  15. SQL根据B表内容修改A表内容,查询表中重复记录,删除掉重复项只保留一条
  16. .NET领域最为流行的IOC框架之一Autofac WebAPI2使用Autofac实现IOC属性注入完美解决方案 AutoFac容器初步
  17. RLE Plots: relative log expression
  18. mvc core2.1 Identity.EntityFramework Core 登录 (三)
  19. WebFlux基础之响应式编程
  20. 安卓开发笔记——TabHost组件(一)(实现底部菜单导航)

热门文章

  1. MyBatis #{} 和 ${} 引用值的用法
  2. 学习-工作:GTD
  3. andrid 上传图片 asp.net 后台接收并保存
  4. tools、site
  5. [UE4]隐藏对象Set Visibility
  6. T-SQL 事务
  7. win7右键菜单调整顺序
  8. 第2章 GNS3和PacketTracer网络模拟器(3)_搭建Packet tracer实验环境
  9. 常见的web安全及防护原理
  10. 08 bash特性--shell脚本编程入门