on 10-14-2008 3:52 PM
Hello Everyone,
In my web dynpro application after I save details. The saved details should be shows as valid as the monday following the date when details were saved.
Eg
sun 1-mo 2 tue 3 wed 4 thu 5 fri 6 sat 7
The validity date should be mon 9 .
Need your expert suggestions on how to capture the system date and dispalying in valid US format for next monday.
Thanks,
Boiler.
Hi,
try this to get the next monday from the current date,
SimpleDateFormat dateFormatter = new SimpleDateFormat("dd/MM/yyyy");
Date dt = new Date(Calendar.getInstance().getTimeInMillis());
Calendar cal = Calendar.getInstance();
cal.setTime(dt);
cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
cal.add(Calendar.DATE,7);
dateFormatter.format(dt); // current date
dateFormatter.format(cal.getTime()); // next monday
Regards,
ramesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Following is the sample code
SimpleDateFormat dateFormatter = new SimpleDateFormat("dd/MM/yyyy");
Date dt = new Date(Calendar.getInstance().getTimeInMillis());
Calendar cal = Calendar.getInstance();
cal.setFirstDayOfWeek(Calendar.MONDAY);
cal.setTime(dt);
cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
System.out.println(dateFormatter.format(dt)); // Prints current date
System.out.println(dateFormatter.format(cal.getTime())); // Prints the date of Monday
Regards
Ayyapparaj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.