on 11-15-2006 9:23 AM
Hi,
Below is the code, where i am initializing a context with the date value. But the date value is not getting assigned to the context. What could be the problem? Kindly help me out.
String s = "12/31/9999";
try {
SimpleDateFormat sd = new SimpleDateFormat("MM/dd/yyyy");
java.sql.Date date1 = (java.sql.Date)sd.parse(s);
Calendar c = Calendar.getInstance();
c.set(2006, 8, 22); //month is zero based
java.sql.Date date2 = (java.sql.Date)c.getTime();
wdContext.currentContextElement().setValidto(date1);
}
Thanks & Regards.
Dhana,
Try this:
String s = "12/31/9999";
try {
/*
//NOT USED ???
SimpleDateFormat sd = new SimpleDateFormat("MM/dd/yyyy");
java.sql.Date date1 = new java.sql.Date( ((java.util.Date)sd.parse(s)).getTime());
*/
Calendar c = Calendar.getInstance();
c.set(2006, 8, 22); //month is zero based
java.sql.Date date2 = new java.sql.Date(c.getTimeInMillis());
wdContext.currentContextElement().setValidto(date2);
}
WD in fact requires java.sql.Date, but many Java API returns java.util.Date and you may not upcast java.util.Date to java.sql.Date
Valery Silaev
SaM Solutions
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Makesure that your code is in init() method
Regards, Anilkumar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dhana,
Are you sure you are using correct variable in last statement (date1 or date2)?
wdContext.currentContextElement().setValidto(date2);
VS
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
String s = "12/31/9999";
try {
SimpleDateFormat sd = new SimpleDateFormat("MM/dd/yyyy");
java.sql.Date date1 = new java.sql.Date( ((java.util.Date)sd.parse(s)).getTime());
Calendar c = Calendar.getInstance();
c.set(2006, 7, 22); //month is zero based
java.sql.Date date2 = new java.sql.Date(c.getTimeInMillis());
wdContext.currentContextElement().setRam(date1);
wdComponentAPI.getMessageManager().reportSuccess("hi"+wdContext.currentContextElement().getRam());
wdComponentAPI.getMessageManager().reportSuccess("hi4"+ date2);
}
this should helps you.
Thanks,
Lohi.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
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.