Reputation: 5592
I got this. But i can't seem to work out how to get the number of days/hours/minutes/seconds left. I ran it in debug mode and it produced: 2776799998. 2776799998 in milliseconds is way to much for 2 days, 1 hour and 15 minutes. (Was when posting this).
What is the correct way?
Calendar cal = Calendar.getInstance();
cal.set(2012, 6, 28, 16, 0);
long endTime = cal.getTimeInMillis();
long currentTime = System.currentTimeMillis();
long remaining = endTime - currentTime;
long seconds = remaining / 1000;
long minutes = seconds / 60;
long hours = minutes / 60;
long days = hours / 24;
Upvotes: 0
Views: 119
Reputation: 6805
The month on the Calendar API starts in 0. So 6 corresponds to July. Maybe that's your problem.
Upvotes: 4
Reputation: 18320
From Calendar's javadoc:
Month value is 0-based. e.g., 0 for January.
Upvotes: 5