Calendar 를 이용하여 해당일자의 요일을 구합니다.
Calendar cal; // 캘린더를 선언 합니다.
int year = cal.get(Calendar.YEAR); // 년 구하기
int month = cal.get(Calendar.MONTH) + 1; // 월 구하기
int day = cal.get(Calendar.DAY_OF_MONTH); // 일 구하기
int week = cal.get(Calendar.WEEK_OF_YEAR); // 년중의 주차 구하기
Calendar calToday= Calendar.getInstance (); // 오늘 일자 구하기
cal.add(Calendar.DAY_OF_MONTH, -1); // 전일자 구하기
cal.add(Calendar.DAY_OF_MONTH, 1); // 다음일 구하기
< switch 문으로 요일구하기 >
switch (cal.get(Calendar.DAY_OF_WEEK)){
case 1:
System.out.println("일요일");
break;
case 2:
System.out.println("월요일");
break;
case 3:
System.out.println("화요일");
break;
case 4:
System.out.println("수요일");
break;
case 5:
System.out.println("목요일");
break;
case 6:
System.out.println("금요일");
break;
case 7:
System.out.println("토요일");
break;
}
'프로그램 참고' 카테고리의 다른 글
SSIS 디버깅이 안될때 (0) | 2015.11.11 |
---|---|
아웃룩 첨부파일이 임시저장로 저장되는 곳 (1) | 2014.12.18 |
SQL server Uniq ID 생성 (0) | 2014.08.18 |
아웃룩 , 구글캘린터 연동 (0) | 2014.04.03 |
SQL Server 테이블 이름 용량 (0) | 2014.03.18 |