Gregoriancalendar 달
-
06-07-2019 - |
문제
GregorianCalendar startDate = new GregorianCalendar(2009, Calendar.JANUARY, 1);
SimpleDateFormat sdf = new SimpleDateFormat("d/m/yyyy");
public void setStart()
{
startDate.setLenient(false);
System.out.println(sdf.format(startDate.getTime()));
}
이 코드를 실행하면 2009 년 1 월 1 일을받습니다. 나는 또한 몇 달을 바꿀 때도 같은 것을 얻습니다. 무엇이 잘못되었고 어떻게 해결할 수 있습니까?
해결책
소문자 'm'은 시간에 분입니다. 대신 대문자 'm'을 사용해야합니다.
SimpleDateFormat sdf = new SimpleDateFormat("d/M/yyyy");
참조 SimpleDateFormat
자세한 내용은 Javadoc.
제휴하지 않습니다 StackOverflow