6

ユーザーから、DatePickerDialog で設定した日付を取得します。取得する日付は次の形式です。

int selectedYear, int selectedMonth, int selectedDay

下の図のように、「日、月、日、年」のようにフォーマットできますか?

ここに画像の説明を入力

4

3 に答える 3

6

これを試すことができます:

SimpleDateFormat sdf = new SimpleDateFormat("EEE-dd-MM-yyyy"); // Set your date format
String currentData = sdf.format(your actual date); // Get Date String according to date format

ここでは、詳細とサポートされているすべての形式を確認できます。

http://developer.android.com/reference/java/text/SimpleDateFormat.html

于 2013-11-12T12:13:07.463 に答える
1

a を使用しSimpleDateFormatて日付をフォーマットします。

    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.YEAR, selectedYear);
    cal.set(Calendar.MONTH, selectedMonth);
    cal.set(Calendar.DAY_OF_MONTH, selectedDay);
    SimpleDateFormat sdf = new SimpleDateFormat();
    String DATE_FORMAT = "EE, MMM dd, yyyy";
    sdf.applyPattern(DATE_FORMAT);
    String formattedDate = sdf.format(cal.getTime());
于 2013-11-12T12:19:07.030 に答える