Java 및 실제로 많은 시스템은 UTC 1970 년 1 월 12 일 오전 12 시부 터 시간을 밀리 초 단위로 저장합니다. 이 숫자는 long으로 정의 할 수 있습니다.
//to get the current date/time as a long use
long time = System.currentTimeMillis();
//then you can create a an instance of the date class from this time.
Date dateInstance = new Date(time);
//you can then use your date format object to format the date however you want.
System.out.println(format1.format(dateInstance));
//to increase by a day, notice 1000 ms = 1 second, 60 seconds = 1 minute,
//60 minutes = 1 hour 24 hours = 1 day so add 1000*60*60*24
//to the long value representing time.
time += 1000*60*60*24;
//now create a new Date instance for this new time value
Date futureDateInstance = new Date(time);
//and print out the newly incremented day
System.out.println(format1.format(futureDateInstance));
날짜에 날짜를 추가하는 것은 좋지 않습니다. 하루가 25 시간 지속되는 DST로 인해 적어도 일 년에 한 번 실패합니다. –
그것은 시간을 늘리는 방법의 예일뿐 endall 고정 솔루션은 아닙니다. 필요한 경우 더 많은 요인을 고려할 수 있습니다. –
그리고 GregorianCalendar를 다시 구현 하시겠습니까? 아뇨, 미안 해요. 날짜 aruthmetics는 올바르게하기가 매우 어렵습니다. 그것은 정말로 당신이 혼자하고 싶지 않은 것입니다. –