パターンに日付があります26/03/2013
。March 2013
Androidで同等の月と年のような形式を取得するにはどうすればよいですか? 私のデートは29-03-2017
この日付を年と月に変換したいと思います。
このような:
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);