on 08-28-2006 5:59 AM
hi
I have this thing to do:
int days=wdContext.currentContext.getNoofdays();
Date date = wdContext.currentContext.getDate();
Date date2 = date + days;
wdContext.currentContext.setDate(date2);
Means i have to add no of days to my date.
And then set my date to the increased date(increase due to addition of days.
Please help me
Regards
Hi
Try this
int days=wdContext.currentContext.getNoofdays();
Date date = wdContext.currentContext.getDate();
String DATE_FORMAT = "yyyy-MM-dd";
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(DATE_FORMAT);
Calendar c1 = Calendar.getInstance();
c1.set((date.getYear()1900), date.getMonth()1 , date.getDate());
c1.add(Calendar.DATE,days);
Date d2=c1.getTime();
java.sql.Date date2=new java.sql.Date(d2.getYear(),d2.getMonth(),d2.getDate());
wdContext.currentContext.setDate(date2);
Kind Regards
Mukesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mukesh,
c1.set((date.getYear()1900), date.getMonth()1 , date.getDate());
In the Above line of code, month + 1 takes u to the next month..right?
bhandari,
The below code is working fine. you can directly use this one.
int days=10; // how many days you want add to the current date String DATE_FORMAT = "yyyy-MM-dd";
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(DATE_FORMAT);
Date date = wdContext.currentContextElement().getDate1();
Calendar c1 = Calendar.getInstance();
if(date != null){
c1.set((date.getYear()+1900), date.getMonth(), date.getDate()); // 2006 Aug 28
c1.add(Calendar.DATE,days);
// In the Same way you can add months and year also
java.util.Date d2 = c1.getTime();
java.sql.Date date2=new java.sql.Date(d2.getYear(),d2.getMonth(),d2.getDate());
wdContext.currentContextElement().setDate2(date2);
}
Hi
This code is working fine
int days=wdContext.currentcontextElement.getDay();
Date date = wdContext.currentContextElement().getTestDate();
String DATE_FORMAT = "dd/mm/yy";
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(DATE_FORMAT);
Calendar c1 = Calendar.getInstance();
c1.set((date.getYear()), date.getMonth() , date.getDate());
c1.add(Calendar.DATE,days);
wdComponentAPI.getMessageManager().reportSuccess(sdf.format(c1.getTime()));
Date d2=c1.getTime();
java.sql.Date date2=new java.sql.Date(d2.getYear(),d2.getMonth(),d2.getDate());
wdContext.currentContextElement().setTestDate(date2);
Kind Regards
Mukesh
Hi,
Use the following code.
String DATE_FORMAT = "yyyy-MM-dd";
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(DATE_FORMAT);
Calendar c1 = Calendar.getInstance();
c1.set(2006, 08 , 28); // 2006 Aug 28
wdComponentAPI.getMessageManager().reportSuccess("Date is : " + sdf.format(c1.getTime()));
c1.add(Calendar.DATE,10);
c1.add(Calendar.MONTH,5);
c1.add(Calendar.YEAR,5);
wdComponentAPI.getMessageManager().reportSuccess("Date + 10 days is : " + sdf.format(c1.getTime()));
Regards,
Saraswathi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
To Add Days into the Date, you need to use java's Calendar Class.
String DATE_FORMAT = "yyyy-MM-dd";
java.text.SimpleDateFormat sdf =
new java.text.SimpleDateFormat(DATE_FORMAT);
Calendar c1 = Calendar.getInstance();
c1.set(1999, 0 , 20); // 1999 jan 20
System.out.println("Date is : " + sdf.format(c1.getTime()));
c1.add(Calendar.DATE,20);
System.out.println("Date + 20 days is : " + sdf.format(c1.getTime()));
Hope it helps you.
Regards,
Maheswaran.B
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.