
IntlDateFormatter 클래스의 getCalendarObject 메서드는 Locale 객체에 따라 달력 객체를 반환합니다.
반환된 달력 객체는 java.util.Calendar 클래스의 인스턴스입니다.
java.util.Calendar 클래스는 달력 연산을 위한 다양한 메서드를 제공합니다.
예를 들어, get() 메서드를 사용하여 달력의 년, 월, 일, 시, 분, 초를 얻을 수 있습니다.
예를 들어, 다음과 같이 사용할 수 있습니다.
Calendar calendar = formatter.getCalendarObject();
int year = calendar.get(Calendar.YEAR);
int month = calendar.get(Calendar.MONTH);
int day = calendar.get(Calendar.DAY_OF_MONTH);
또한, set() 메서드를 사용하여 달력의 년, 월, 일, 시, 분, 초를 설정할 수 있습니다.
예를 들어, 다음과 같이 사용할 수 있습니다.
Calendar calendar = formatter.getCalendarObject();
calendar.set(Calendar.YEAR, 2022);
calendar.set(Calendar.MONTH, Calendar.DECEMBER);
calendar.set(Calendar.DAY_OF_MONTH, 25);
이와 같이 java.util.Calendar 클래스의 메서드를 사용하여 달력의 속성을 얻거나 설정할 수 있습니다.
2025-03-05 16:11