Ali Imran
Ali Imran

Reputation: 9217

Android 4.3 jelly Bean Time format issue

My date format is this "yyyy-MM-dd" and when i get month using this function it return me wrong format of month. For example instead of "July" it return me only "J"

here is the function:

public static String getMonthName(String date) {

    Date mDate = Utils.parseDate(date);
    SimpleDateFormat sdf = new SimpleDateFormat("MMMMM");
    String time = sdf.format(mDate);
    return time;

}

andy idea what to do?

Edit: and here is my parseDate(String date) function

public static Date parseDate(String date) {
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        try {
            return formatter.parse(date);
        } catch (ParseException e) {
            e.printStackTrace();
            return new Date();
        }
    }

Upvotes: 6

Views: 1172

Answers (1)

Flaxie
Flaxie

Reputation: 540

I think you have one M to much

M:1 MM:01 MMM:Jan MMMM:January MMMMM:J

Upvotes: 5

Related Questions