【发布时间】:2012-05-24 04:56:49
【问题描述】:
我在应用程序中的日期显示为 07/10/2011(dd/MM/yyyy)...我希望日期格式为 2011 年 10 月 7 日,采用 android 编码。请帮助作为 Android 新手
【问题讨论】:
标签: android date-format simpledateformat android-date
我在应用程序中的日期显示为 07/10/2011(dd/MM/yyyy)...我希望日期格式为 2011 年 10 月 7 日,采用 android 编码。请帮助作为 Android 新手
【问题讨论】:
标签: android date-format simpledateformat android-date
DateFormat f = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.ENGLISH);
String dateString = f.format(new Date());
【讨论】:
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));
}
【讨论】:
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
【讨论】:
String mydate = java.text.DateFormat.getDateTimeInstance().format(Calendar.getInstance().getTime());
TextView _dateText=(TextView)_view.findViewById(R.id.dateTextView);
_dateText.setText(""+mydate);
【讨论】: