Month issue in SimpleDateFormat class

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


mm should be capital MM. Beacuse

mm represent minute MM represent Month

So your format should be like

SimpleDateFormat input = new SimpleDateFormat("yyyy-MM-dd");

mm represents minutes, so when you use mm, it will print minutes instead of month.

While MM represents months. You need to add like this:

SimpleDateFormat input = new SimpleDateFormat("yyyy-MM-dd");

SimpleDateFormat input = new SimpleDateFormat("yyyy-mm-dd");

should be

SimpleDateFormat input = new SimpleDateFormat("yyyy-MM-dd");

mm should be MM