In android, when executing the code snippet below, date3 returns -1
booking_year2 = 2038;
booking_month2 = 1;
booking_day2 = 17;
Time t = new Time();
t.set(booking_day2, booking_month2 - 1, booking_year2);
long date3 = t.toMillis(false);
//date3 returns 2147451300000 as expected
//But if we run with values:
booking_year2 = 2038;
booking_month2 = 1;
booking_day2 = 18;
//date3 returns -1
While the time object "t" was expecting a value in all conditions, the long value returned by toMillis () is -1. And also for all upper date values after jan 19, 2038, the toMillis () function returns only -1, not the expected value.
I did not understand and did not find a suitable reason or solution for this. Please let me know if I am doing something wrong or there is another way to find millisecond values after this date.
source
share