cancel
Showing results for 
Search instead for 
Did you mean: 

How to convert (YYYY-MM-DD) to (DD-MM-YYYY)

Former Member
0 Kudos

Hi Guys,

I have one doubt on WDJ,

While exporting data into Excel Sheet having date format is showing like the format (YYYY-MM-DD).

But I need to convert into this format (DD-MM-YYYY). Can any one suggest me? How to convert (YYYY-MM-DD) to (DD-MM-YYYY)

I was written this code for getting date from ECC System and Convert to String type.

Date DelivDate = wdContext.nodePoDetails_ExcelData().getPoDetails_ExcelDataElementAt(i).getDeliv_Date();

String DelivDate1 = DelivDate.toString();

Date ShtDate = wdContext.nodePoDetails_ExcelData().getPoDetails_ExcelDataElementAt(i).getStat_Date();

String ShtDate1 = ShtDate.toString();

//wdComponentAPI.getMessageManager().reportSuccess("ShtDate1::"+ShtDate1);

Date ExptShpDate = wdContext.nodePoDetails_ExcelData().getPoDetails_ExcelDataElementAt(i).getExpt_Shp_Date();

String ExptShpDate1 = ExptShpDate.toString();

Regards

Vijay Kalluri

Accepted Solutions (1)

Accepted Solutions (1)

Greg_Austin
Active Participant
0 Kudos

Hi Vijay,

Since you already have a Date object I would use the SimpleDateFormat class to format the String the way you want. Something like this:

SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");

sdf.format(date);

Note the M for month is upper case, m is for minute.

-Greg

Former Member
0 Kudos

Hi Greg,

Still i haven't resolve the issue.

SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");

sdf.format(date);

Date DelivDate = wdContext.nodePoDetails_ExcelData().getPoDetails_ExcelDataElementAt(i).getDeliv_Date();

String DelivDate1 = DelivDate.toString();

could you please give me more clarification on above code. if possible.

Regards

Vijay Kalluri

Greg_Austin
Active Participant
0 Kudos

Hi Vijay,

sdf.format(date) doesn't actually change your object, just returns a String representation of that object in the format you want.




Date DelivDate = wdContext.nodePoDetails_ExcelData().getPoDetails_ExcelDataElementAt(i).getDeliv_Date(); 
String DelivDate1 = DelivDate.toString();  //will give yyyy-MM-dd

SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
String DelivDate2 = sdf.format(DelivDate); // will give dd-MM-yyyy


Former Member
0 Kudos

Thanks Grag,

I tried it ,Now its Working fine . I Would like to know about your gmail detail, so that i can add into orkut Fourms

Regards,

Vijay

Answers (0)