Pin It

How to display or get list of week days names in Java ?.

Program to implement how to display or get list of week days names in Java

package com.hubberspot.lists;

import java.text.DateFormatSymbols;

public class WeekDaysList {

	public static void main(String[] args) {

		// Create a DateFormatSymbols instance
		DateFormatSymbols dfs = new DateFormatSymbols();

		// DateFormatSymbols instance has a method by name
		// getWeekdays() which returns back an array of 
		// week days name
		String[] arrayOfWeekDaysNames = dfs.getWeekdays();

		// loop over each day name and printing on the 
		// console
		for( String dayName : arrayOfWeekDaysNames ) { 

			System.out.println(dayName);

		}

		dfs = new DateFormatSymbols();

		// DateFormatSymbols instance has a method by name
		// getShortWeekdays() which returns back an array of 
		// week days name in short forms
		String[] arrayOfShortWeekDaysNames = dfs.getShortWeekdays();

		// loop over each day name and printing on the 
		// console
		for( String dayName : arrayOfShortWeekDaysNames ) { 

			System.out.println(dayName);

		}

	}

}



Output of the program : 


 
Please Give Us Your 1 Minute In Sharing This Post!
SOCIALIZE IT →
FOLLOW US →
SHARE IT →
Related Posts Plugin for WordPress, Blogger...

Post your related queries below ...

comments powered by Disqus
Powered by Blogger.
 
© 2012 Learn Java by Examples Template by Hubber Spot