cancel
Showing results for 
Search instead for 
Did you mean: 

converting date from string to Calendar format

Former Member
0 Kudos

How to convert Date from string format to java.util.Calendar format in WDJ for saving in MDM tables?

Accepted Solutions (1)

Accepted Solutions (1)

former_member40425
Contributor
0 Kudos

Hi Isha,

You can use following code to convert string date to calender format.


String stringDate="23-Aug-10";
SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy");
Date date = formatter.parse(stringDate);
Calendar calender = Calendar.getInstance();
calender.setTime(date);

After conveting into calender you can use DateTimeValue class to save in MDM table.


DateTimeValue mdmDate = new DateTimeValue(calendar);

I hope it helps.

Regards,

Rohit

Answers (1)

Answers (1)

vijay_kumar49
Active Contributor
0 Kudos

Hi,

Please check this code.


import java.text.DateFormat; 
import java.text.ParseException; 
import java.text.SimpleDateFormat; 
import java.util.Date; 
 
DateFormat df = new SimpleDateFormat("dd/MM/yyyy"); 
try { 
Date today = df.parse("19/08/2011"); 
System.out.println("Today = " + df.format(today)); 
} 
catch (ParseException e) 
{ 
e.printStackTrace(); 
} 

Please reffer [this|; and [conver String to Date|]thread.

Hope this helps!!

Thanks & Regards

Vijay

Edited by: VijaySAPEP on Aug 19, 2011 6:59 PM