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

}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM