글목록

2015. 2. 12.

[Java] How to find Day of Week

   
 
 import java.text.DateFormatSymbols;
 
 public class WeekDayNames{ 

        public static void main(String args[]) {
 
        DateFormatSymbols dateFormatSymbols = new DateFormatSymbols();
        String[] weekdays = dateFormatSymbols.getWeekdays();
 
        for (int i = 0; i < weekdays.length; i++){

            String day = weekdays[i];
            System.out.println("day : " +day);

        }
    }
}
   
 
 public String makeWeekDay(){
  
  Calendar cal = Calendar.getInstance();
  
   String[] dayOfWeek={"일","월","화","수","목","금","토"};
   String weekday=dayOfWeek[cal.get(Calendar.DAY_OF_WEEK)-1];
  
  return weekday;
 }

댓글 없음:

댓글 쓰기