我在应用程序中的日期显示为07/10/2011(dd / MM / yyyy)...我希望日期格式为10月7,2011在android编码中。请帮助我作为Android的新手
答案 0 :(得分:3)
DateFormat f = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.ENGLISH);
String dateString = f.format(new Date());
答案 1 :(得分: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));
}
答案 2 :(得分: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
答案 3 :(得分:0)
String mydate = java.text.DateFormat.getDateTimeInstance().format(Calendar.getInstance().getTime());
TextView _dateText=(TextView)_view.findViewById(R.id.dateTextView);
_dateText.setText(""+mydate);