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

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);
}

}

猜你喜欢

转载自www.cnblogs.com/THEONLYLOVE/p/9117723.html