Select Language
Super Contributor
spring_suvarna
Posts: 260
Registered: 02-25-2009
0

Dates of next 14 days

Hello,

 

In my App. i need to display next 14 days Dates from current day.

How can i get next 14 dates?

i am able to get current date.

 

Thanks in advance.

Trusted Contributor
ydaraishy
Posts: 193
Registered: 09-30-2009
0

Re: Dates of next 14 days

You can convert the current date time to milliseconds and vice versa. Add how many milliseconds there are in a day and convert back to a date, fourteen times.

Super Contributor
spring_suvarna
Posts: 260
Registered: 02-25-2009
0

Re: Dates of next 14 days

Bingo !!

 

i just now tried the same thing and its working fine.

 

1 day = 86400000 millis

 

 

long currentTime = System.currentTimeMillis(); 

currentTime += 86400000; // for 14 times

 

 

Expert III
peter_strange
Posts: 3,745
Registered: 07-14-2008
0

Re: Dates of next 14 days

Be aware that this approach may not work around DST change time, because days can be shorter or longer than 24 hours. 

 

I prefer to use the DateTimeUtilities.ONE_DAY type constants when incrementing/decrementing the time.

Super Contributor
spring_suvarna
Posts: 260
Registered: 02-25-2009
0

Re: Dates of next 14 days

Ohh

 

I should take care of it. I will work around and will be back if any queries or solutions.

 

Thanks peter_strange