cancel
Showing results for 
Search instead for 
Did you mean: 

problem in converting date into string

Former Member
0 Kudos

Hi

I have a value attribute or type date when i convert it to string it returns me some wrong value follwoing is the code from which i am converting it to string

wdContext.currentContextElement().setTEST(wdContext.currentContextElement().getFrmDateValue()+"");

wdContext.currentContextElement().setTEST(wdContext.currentContextElement().getFrmDateValue().toString());

can any one tell me what could be the problem and how i should convert it to String

Thanks

Ninad

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

Try this out

SimpleDateformat dateform = new SimpleDateformat("yyyyMMdd");

String x = dateform.format(new Date(wdContext.currentContextElement().getFrmDateValue()));

wdContext.currentContextElement().setTEST(x);

-Rathna

Former Member
0 Kudos

Hi Rathna

I tried this option also but it gives me the error <b>The Constructor Date(Date) is undefined</b>

Thanks

Ninad

Former Member
0 Kudos

Hi,

Are you using the Date format to convert the date to

string?

Regards

Saravanan K

Former Member
0 Kudos

yes i am useing I gess this might be the problem of time zone as i am storing only date in that case the time will be 00:00:00 and the time zone for our server is +1:00 so when it converts the date is it considering the time zone and converting it to GMT could this be the problem.

This is what come to my mind but it looks very funy and irrelevent.

Thanks

Ninad

Former Member
0 Kudos

Hi,

You can use a code like this:


SimpleDateFormat df  = new SimpleDateFormat("yyyyMMdd");
String formattedDate = df.format(wdContext.currentContextElement().getFrmDateValue());

Regards,

Satyajit.

Former Member
0 Kudos

Hi Satyajit,

I tried this option but i am getting one day previous date of the actual date in frmDateValue so where could be the problem

Thanks

Ninad

Former Member
0 Kudos

There are many ways to format a date, see class java.text.DateFormat and its subclass SimpleDateFormat.

Armin

Former Member
0 Kudos

Hi Armin,

I am have a date in yyyy-MM-dd fromat and i want to have it to be converted in yyyyMMdd format so can you give me the code to convert it because i am new to all these things

thanks

Ninad

Former Member
0 Kudos

HI,

SimpleDateFormat fmtDatePlain = new SimpleDateFormat("yyyyMMdd");

String formattedDate = fmtDatePlain.format(Your Date);

Atlast your formatted date is stored in formatted date

This will help you

Regards

Saravanan K