(九)Java工具类DateFormatUtils详解

日期和时间格式化实用程序和常量

  • public static String format(Calendar calendar, String pattern)

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

        输出结果:2018-01-23 19:50:55

public static String format(Calendar calendar, String pattern,TimeZone timeZone)

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

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

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

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

public static String format(Date date,String pattern,TimeZone timeZone)

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

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

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

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

    说明:使用UTC时区将日期/时间格式化为特定的模式;
    参数:date-要格式化的时间;pattern-格式化的模式;
    返回值:格式化的日期;
    
  • 1
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
编译原理是计算机专业的一门核心课程,旨在介绍编译程序构造的一般原理和基本方法。编译原理不仅是计算机科学理论的重要组成部分,也是实现高效、可靠的计算机程序设计的关键。本文将对编译原理的基本概念、发展历程、主要内容和实际应用进行详细介绍编译原理是计算机专业的一门核心课程,旨在介绍编译程序构造的一般原理和基本方法。编译原理不仅是计算机科学理论的重要组成部分,也是实现高效、可靠的计算机程序设计的关键。本文将对编译原理的基本概念、发展历程、主要内容和实际应用进行详细介绍编译原理是计算机专业的一门核心课程,旨在介绍编译程序构造的一般原理和基本方法。编译原理不仅是计算机科学理论的重要组成部分,也是实现高效、可靠的计算机程序设计的关键。本文将对编译原理的基本概念、发展历程、主要内容和实际应用进行详细介绍编译原理是计算机专业的一门核心课程,旨在介绍编译程序构造的一般原理和基本方法。编译原理不仅是计算机科学理论的重要组成部分,也是实现高效、可靠的计算机程序设计的关键。本文将对编译原理的基本概念、发展历程、主要内容和实际应用进行详细介绍编译原理是计算机专业的一门核心课程,旨在介绍编译程序构造的一般原理和基本

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值