This is a follow up post to my other post about the Calendar Class ENUM DayOfWeek question.
***My question would be to ask for feedback from the moderators regarding the value of this class and method in creating calendar related applications***
This is new information and solves (for me) the purpose of outputting the TEXT form of the days of the week using the class DateFormatSymbols, and
the getWeekdays() method in addition to a for loop. Code example at the end of this post.
Per http://docs.oracle.com/javase/7/docs/api/java/text/DateFormatSymbols.html,
"DateFormatSymbols is a public class for encapsulating localizable date-time formatting data, such as the names of the months, the names of the days of the week, and the time zone data. DateFormat and SimpleDateFormat both use DateFormatSymbols to encapsulate this information."
Per http://devmanuals.com/tutorials/java/corejava/DateTimes/DateFormatSymbolsgetWeekdays.html,
"The getWeekdays() method returns a string array of each weekdays' name."
The thing to note is that the CONSTANT FIELD VALUES for the days of the week start with SUNDAY = 1 thru SATURDAY = 7. There is no 0th value.
The String array that holds the text version of the days of the week does have a 0th element, however, it is empty.
Thus, the for loop should start with -1- to begin with SUNDAY.
Here is the code per the link above:
Output is:
Full name of day : Sunday
Full name of day : Monday
Full name of day : Tuesday
Full name of day : Wednesday
Full name of day : Thursday
Full name of day : Friday
Full name of day : Saturday
------------------------------------------------------------
For me, this brings the process of using the Calendar and Date classes along with the related classes for formatting the output of the fields full circle.
***My question would be to ask for feedback from the moderators regarding the value of this class and method in creating calendar related applications***
This is new information and solves (for me) the purpose of outputting the TEXT form of the days of the week using the class DateFormatSymbols, and
the getWeekdays() method in addition to a for loop. Code example at the end of this post.
Per http://docs.oracle.com/javase/7/docs/api/java/text/DateFormatSymbols.html,
"DateFormatSymbols is a public class for encapsulating localizable date-time formatting data, such as the names of the months, the names of the days of the week, and the time zone data. DateFormat and SimpleDateFormat both use DateFormatSymbols to encapsulate this information."
Per http://devmanuals.com/tutorials/java/corejava/DateTimes/DateFormatSymbolsgetWeekdays.html,
"The getWeekdays() method returns a string array of each weekdays' name."
The thing to note is that the CONSTANT FIELD VALUES for the days of the week start with SUNDAY = 1 thru SATURDAY = 7. There is no 0th value.
The String array that holds the text version of the days of the week does have a 0th element, however, it is empty.
Thus, the for loop should start with -1- to begin with SUNDAY.
Here is the code per the link above:
Output is:
Full name of day : Sunday
Full name of day : Monday
Full name of day : Tuesday
Full name of day : Wednesday
Full name of day : Thursday
Full name of day : Friday
Full name of day : Saturday
------------------------------------------------------------
For me, this brings the process of using the Calendar and Date classes along with the related classes for formatting the output of the fields full circle.