在Android中日期转换为月份和年份
我的日期是2013年3月26日。如何在Android中获得与2013年3月类似的月份和年份格式?我的约会日期是2017年3月29日 我想将此日期转换为年和月。如下所示:在Android中日期转换为月份和年份,android,datetime,Android,Datetime,我的日期是2013年3月26日。如何在Android中获得与2013年3月类似的月份和年份格式?我的约会日期是2017年3月29日 我想将此日期转换为年和月。如下所示: String strdate = "26/03/2013"; SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); Date yourdate = sdf.parse(str); SimpleDateFormat sdf = new SimpleD
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);
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();
}
勾选这个,否则你可以用漂亮的答案。太好了+你让我脸红了!:)