안드로이드 개발 질문/답변
(글 수 45,052)
import java.sql.date;
Date date = new Date(2010. 5. 24);
이렇게 하고 디버그 모드에서 date를 보면,
"3910-05-24" 이렇게 나옵니다.
년도를 하나씩 더해도 언제나 딱 1900년이 더해지는데 이렇게 작동하는게 맞는건가요? ㅠㅠ
소박하지만 사랑받는 앱을 만들어가고 싶은 소규모 개발 팀입니다
2010.05.24 10:39:12
android에 있는 Date를 사용하시는 것이 나을듯 합니다. import 추천시 2가지 나오는데 android에 있는 것을 사용.
java에서도 Date보다는 Calendar를 사용하는 것을 추천합니다.
2010.05.24 10:40:48
API 보면 나왔있습니다. 년도는 1900년 부터 시작 되도록 합니다. 즉 1900을 빼야 원하는 년도가 됩니다.
public Date (int theYear, int theMonth, int theDay)
Since: API Level 1
This constructor is deprecated.
Use the
constructor Date(long)
.
Constructs a Date
object corresponding to the supplied year,
month and day.
Parameters
theYear | the year, specified as the year minus 1900. Must be in the range
[0,8099] . |
---|---|
theMonth | the month, specified as a number with 0 = January. Must be in the range
[0,11] . |
theDay | the day in the month. Must be in the range [1,31] . |