Android : Error SimpleDateFormat Unknown pattern character 'u'

I use java 1.7.25 but found this error. what should I do?

FATAL EXCEPTION: main
java.lang.IllegalArgumentException: Unknown pattern character 'u'
        at java.text.SimpleDateFormat.validateFormat(SimpleDateFormat.java:264)
        at java.text.SimpleDateFormat.validatePattern(SimpleDateFormat.java:319)
        at java.text.SimpleDateFormat.<init>(SimpleDateFormat.java:365)
        at java.text.SimpleDateFormat.<init>(SimpleDateFormat.java:249)

Here is my code

    public static int getDayNumberOfWeek(int day, String monthString, int yyyy) {
//http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html
    int dayNumberOfWeek = 1;
    final String inputFormat = "MMM/dd/yyyy";
    final String outputFormat = "u";
    String dayString2Digit = DateTimeHelper.getTwoDigit(day);
    String inputTimeStamp = monthString + "/" + dayString2Digit + "/" + String.valueOf(yyyy);
    try {
        dayNumberOfWeek =Integer.valueOf(TimeStampConverter(inputFormat, inputTimeStamp,
                                                            outputFormat));
    }
    catch (ParseException e) {
        e.printStackTrace();
    }
    return dayNumberOfWeek;
}
Jon Skeet
people
quotationmark

I use java 1.7.25

No, you don't - not if you're running on Android. You need to look at the Android documentation, not the Java 7 docs.

If you look at the Android SimpleDateFormat documentation you'll see that u isn't listed there. I don't believe there's a format pattern character for "day of week as a number" in Android.

Were you really looking for that though? If you just want the day of the week as a number (without anything else) you can always use

String text = String.valueOf(calendar.get(Calendar.DAY_OF_WEEK));

people

See more on this question at Stackoverflow