I am trying to find out weekdays using DateFormatSymbols and here is a short programe
String[] shortWeekdays = new DateFormatSymbols().getShortWeekdays();
System.out.println(shortWeekdays.length);
for (int i = 0; i < shortWeekdays.length; i++) {
String shortWeekday = shortWeekdays[i];
System.out.println("shortWeekday = " + shortWeekday);
}
and it is giving me folloiwng output
- shortWeekday =
- shortWeekday = Sun
- shortWeekday = Mon
- shortWeekday = Tue
- shortWeekday = Wed
- shortWeekday = Thu
- shortWeekday = Fri
- shortWeekday = Sat
i am not sure why its giving total length as 8 while it should give it as 7
The range of values for Calendar.{SUNDAY, MONDAY, ... SUNDAY }
is 1-7. The docs for getShortWeekDays()
state:
Returns: the short weekday strings. Use Calendar.SUNDAY, Calendar.MONDAY, etc. to index the result array.
So I'd expect an array which can be indexed with values 1-7... which means it has to have 8 elements (as all arrays in Java are 0-based).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With