2012-04-25 9 views
0

システムから今日の日付であるsdfDateTime.format(new Date(System.currentTimeMillis()));を取得して、SimpleDateFormatの動作を知っています。 SimpleDateFormatは文字列を取得して日付をフォーマットできますか?文字列があるとします:String dateStr = "04/05/2012";「2012年4月5日」にどのように書式を設定しますか?SimpleDateFormatは文字列に基づいて日付をフォーマットできますか?

答えて

1
DateFormat inputFormat = new SimpleDateFormat("MM/dd/yyyy"); 
inputFormat.setLenient(false); 
DateFormat outputFormat = new SimpleDateFormat("MMMM dd, yyyy"); 
outputFormat.setLenient(false); 

String inputDateAsString = "04/05/2012"; 
Date inputDate = inputFormat.parse(inputDateAsString); 
System.out.println(outputFormat.format(inputDate)); 

のための延長&を使用するように、簡単に非常に役立つライブラリです。

+0

ニース!まさに私が探していたものです - ありがとうダフィモ! – kirktoon1882

関連する問題