Say your looking for next tuesday:
int desiredDay = 2; // tuesday
Date currDate = new Date();
int currDay = currDate.getDay();
int daysToJump = (7+desiredDay-currDay)%7
if (daysToJump == 0) daysToJump = 7;
Date nextTuesday = new Date(currDate.getTime() + daysToJump * 24 * 60
* 60 * 1000);
No test
Thank you for your quick answers.
However, I dont know many days i must add to get to the next "day of
week". Or should I make a huge and ugly if statement on the current
day?
For example, today we are wednesday, when is the next tuesday?
--
You received this message because you are subscribed t
I have not tested the edge conditions around daylight savings times,
but I found this useful:
import com.google.gwt.user.datepicker.client.CalendarUtil;
Date now = new Date();
int nDays = 1;
CalendarUtil.addDaysToDate(now, nDays);
The number of days can be negative if you need to go back. There
This is true...but the mistake is just one hour, and the day when daylight
saving
time happens.
The Date class is not that correct:) , but the calendar class wich shouldv
been the repair is not correct also..once joshua bloch on a presentation
said...when u re-doing something, at list do it right:
Am 16.11.2010 16:30, schrieb Blagoja Chavkoski:
> Just use "now"= new Date(), and then from this date do what ever u like to do
>
> one day after... new Date ( new Date().getTime() + 24 * 60 * 60 * 1000)
> one day before... new Date ( new Date().getTime() - 24 * 60 * 60 * 1000)
>
> one week afte
Hi,
Just use "now"= new Date(), and then from this date do what ever u like to
do
one day after... new Date ( new Date().getTime() + 24 * 60 * 60 * 1000)
one day before... new Date ( new Date().getTime() - 24 * 60 * 60 * 1000)
one week after ...new Date ( new Date().getTime() + 7 * 24 * 60 * 60
Hello,
I'm just starting with GWT and Dates (so sad I can't use Calendar),
and I have no idea how to get the date of the next tuesday (or any day
of the week) without using Calendar. I've been trying that to do that
for a few hours now so any help would be appreciated.
Regards
--
You received th