2

我在应用程序中的日期显示为 07/10/2011(dd/MM/yyyy)...我希望日期格式为 2011 年 10 月 7 日,采用 android 编码。请帮助作为Android新手

4

4 回答 4

3
    DateFormat f = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.ENGLISH);
    String dateString = f.format(new Date());
于 2012-05-24T05:03:44.057 回答
3
private void dateformation() {
        SimpleDateFormat dateformate = new SimpleDateFormat("MMM dd, yyyy");
        Calendar currentDate = Calendar.getInstance();

        String currentDateStr = dateformate.format(currentDate.getTime());
        Log.i("Infoe ", " " + currentDateStr.toString());
        System.out.println("Current date is :  " + currentDateStr);
        // //=== OR

        SimpleDateFormat sdf = new SimpleDateFormat("MMM dd, yyyy");

        sdf.applyPattern("MMM dd, yyyy");
        Date x = new Date(currentDate.get(Calendar.YEAR) - 1900,
                currentDate.get(Calendar.MONTH),
                currentDate.get(Calendar.DAY_OF_MONTH));
        Log.i("Infoe ", " " + sdf.format(x));
        System.out.println(sdf.format(x));

    }

日期格式类型

于 2012-05-24T05:44:46.857 回答
2

SimpleDateFormat dateFormat= new SimpleDateFormat("MMM dd, yyyy", Locale.US); dateFormat.format(new Date(0)));

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

于 2012-05-24T05:03:24.257 回答
0
String mydate = java.text.DateFormat.getDateTimeInstance().format(Calendar.getInstance().getTime());

    TextView _dateText=(TextView)_view.findViewById(R.id.dateTextView);
    _dateText.setText(""+mydate);
于 2012-05-24T05:01:13.010 回答