Boost logo

Boost Users :

From: Roman Morokutti (roman_vbg_at_[hidden])
Date: 2005-10-26 02:26:43


Is it possible to parse a date out from a string
like this? The example below is from a java program.

     private static final String PLANSTART_PATTERN = "dd.MM.yyyy HH:mm";

     /**
      * Converts a String of type 01.01.2005 to a
      * CDate object
      * @param sForcamDate
      * @return the converted object
      */
     private CDate convertToCDate(String sForcamDate, String sPattern)
     {
         if (sForcamDate == null || sForcamDate.length() == 0)
             return null;

         try
         {
             SimpleDateFormat sdf = new SimpleDateFormat(sPattern,
                 Locale.getDefault());
             sdf.parse(sForcamDate);
             Calendar cal = sdf.getCalendar();
             return new CDate(cal.getTime());
         }
         catch (ParseException ex)
         {
             return null;
         }
     }

For more information on SimpleDateFormat see:
http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net