Calendar today = new GregorianCalendar();
DateFormate dateFormat=new SimpleDateFormat("yyyyMMdd");
date=dateFormat.format(today);
Java字串轉日期範例
1.//欲轉換的日期字串2.String dateString = "20010-03-02 20:25:58";3.//設定日期格式4.SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");5.//進行轉換6.Date date = sdf.parse(dateString);7.System.out.println(date);
http://cooking-java.blogspot.tw/2010/03/java-string-to-date.html
Java 日期轉字串範列
1.//目前時間2.Date date = new Date();3.//設定日期格式4.SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");5.//進行轉換6.String dateString = sdf.format(date);7.System.out.println(dateString);
http://cooking-java.blogspot.tw/2010/03/java-date-to-string.html
http://stackoverflow.com/questions/3583384/converting-a-calendar-object-into-a-string-in-java-with-format-yyyy-mm-dd-hhmm
http://weick.iteye.com/blog/227707
沒有留言:
張貼留言