我的模式爲26/03/2013
。 Android中如何獲得像March 2013
格式的等效月份和年份?我的約會是29-03-2017
在Android中將日期轉換爲月份和年份
我想將此日期轉換爲年份和月份。
我的模式爲26/03/2013
。 Android中如何獲得像March 2013
格式的等效月份和年份?我的約會是29-03-2017
在Android中將日期轉換爲月份和年份
我想將此日期轉換爲年份和月份。
像這樣:
try {
String dateString = "26/03/2013";
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
Date date = sdf.parse(dateString);
SimpleDateFormat outputFormat = new SimpleDateFormat("MMMM yyyy");
String formattedDate = outputFormat.format(date);
Log.d(TAG, "Got the date: " + formattedDate);
} catch (ParseException e) {
e.printStackTrace();
}
String strdate = "26/03/2013";
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
Date yourdate = sdf.parse(str);
SimpleDateFormat sdf = new SimpleDateFormat("MMMM yyyy");
String yourfinaldate = sdf.format(yourdate);
檢查此[鏈接](http://stackoverflow.com/a/14081940/2345913),也可以使用[SimpleDateFormat的(HTTP://開發商。 android.com/reference/java/text/SimpleDateFormat.html) – CRUSADER