Posts

Showing posts with the label To change String to date

How to change the String Value to Date Value without Hardcoded String value

If we have a Method updateStatusBySales1(bean, bean.dispatcheddate ); In this method we have dispatcheddate . this dispatcheddate is assigned here as String . While inserting into table it will through error. Because in the database table the dispatched date is assigned as date format. Want to change the dispatched date value as date. How to change the String value into date without hardcoded the value... While Surfing the net i found that all the examples given is hard coded value.  For example String str = "07/02/2010"  SimpleDateFormat formatter = new SimpleDateFormat ( "dd-MMM-yyyy" ) ; String dateInString = "07/02/2010" ; try { Date date = formatter . parse ( dateInString ) ; System . out . println ( date ) ; System . out . println ( formatter . format ( date ) ) ; } catch ( ParseException e ) { e . printStackTrace ( ) ; }  -------------------------------- Here i will show you Records fetching from excel ...