Search This Blog

Friday, October 11, 2013

Convert string to jbo date

Make sure the format of the date is set as per your requirement. 

                  formatter = new SimpleDateFormat("EEE MMM d hh:mm:ss z yyyy");
                  date = formatter.parse(aDate);
                  java.sql.Date sqlDate = new java.sql.Date(date.getTime());
                  oracle.jbo.domain.Date jboDate = new oracle.jbo.domain.Date(sqlDate);

If you want the date to be locale specific, use the following

                 formatter = new SimpleDateFormat(pattern, currentLocale); 

Here are some customized Date and Time formats (from Oracle Site)


Customized Date and Time Formats
Pattern Output
dd.MM.yy 30.06.09
yyyy.MM.dd G 'at' hh:mm:ss z 2009.06.30 AD at 08:29:36 PDT
EEE, MMM d, ''yy Tue, Jun 30, '09
h:mm a 8:29 PM
H:mm 8:29
H:mm:ss:SSS 8:28:36:249
K:mm a,z 8:29 AM,PDT
yyyy.MMMMM.dd GGG hh:mm aaa 2009.June.30 AD 08:29 AM