2011-07-21 7 views

答えて

1

java-meでは、日付の書式設定にjava.util.Calendarパッケージを使用できます。

private void outputDateUsingCalendar(Date date) { 
    Calendar calendar = Calendar.getInstance(); 
    calendar.setTime(date); 
    StringBuffer sb = new StringBuffer(); 

    int day = calendar.get(Calendar.DAY_OF_MONTH); 
    sb.append(numberToString(day)); 
    sb.append("-"); 
    int month = calendar.get(Calendar.MONTH) + 1; 
    sb.append(numberToString(month)); 
    sb.append("-"); 
    sb.append(calendar.get(Calendar.YEAR)); 

    StringItem item = new StringItem("Using Calendar", sb.toString()); 
    mainForm.append(item); 
} 
:ここ

このtutorial on displaying the date and time in Java MEからの抜粋です