Friday, April 9, 2010

Convert java.lang.String to oracle.jbo.domain.Date

This is a way of converting a given date  as a string to oracle.jbo.domain.Date.

/**
*Converts a String to oracle.jbo.domain.Date
* @param aDate
* @return oracle.jbo.domain.Date or null.
*/
public oracle.jbo.domain.Date castToJBODate(String aDate){
          DateFormat formatter;
          java.util.Date date;

          if(aDate!=null){

            try {

              formatter = new SimpleDateFormat("dd/MM/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);

                return jboDate;
               } catch (ParseException e) {

                        e.printStackTrace();
                }

         }

         return null;
}

3 comments:

LinkWithin

Related Posts Plugin for WordPress, Blogger...