码迷,mamicode.com
首页 > 编程语言 > 详细

java按照指定格式输出系统时间

时间:2018-05-31 19:17:14      阅读:197      评论:0      收藏:0      [点我收藏+]

标签:new   str   date()   系统时间   form   格式   ati   imp   输出   

public class TimeFour {
public static void main(String[] args) throws ParseException{
TimeFour four = new TimeFour();
four.test();
}

public void test() throws ParseException{
Date date = new Date();

DateFormat df3 = new SimpleDateFormat("yyy-MM-dd HH-mm-ss");
DateFormat df4 = new SimpleDateFormat("yyy年MM月dd日 HH时mm分ss秒");
System.out.println("按照指定格式 yyyy年MM月dd日 hh时mm分ss秒 ,区域为中文:" + df4.format(date));
System.out.println("按照指定格式 yyyy年MM月dd日 hh时mm分ss秒 ,区域为中文:" + df3.format(date));

Date date4 = df4.parse("2007年11月30日 02时51分18秒");
System.out.println(date4);
}

}

java按照指定格式输出系统时间

标签:new   str   date()   系统时间   form   格式   ati   imp   输出   

原文地址:https://www.cnblogs.com/THEONLYLOVE/p/9117723.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!