String expiryDate = "2016-03-14";
private String formatDateTime(String expiryDate, String expiryTime) {
SimpleDateFormat input = new SimpleDateFormat("yyyy-mm-dd");
SimpleDateFormat output = new SimpleDateFormat("MMM, dd, yyyy");
try {
String formattedDate = output.format(input.parse(expiryDate ));// parse input
return formattedDate + ", " + expiryTime;
} catch (ParseException e) {
e.printStackTrace();
}
return null;
}
However when it returns it gives Jan, 14, 2016.
The desired output was Mar,14,2016
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…