Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8851

Re: String to date conversion error

$
0
0

     Fayaz,

 

        SimpleDateFormat formatter =newSimpleDateFormat("dd/MM/yyyy");

        String dateInString ="7/12/2013";

 

        try{

               Date date = formatter.parse(dateInString);

               System.out.println(date);

               System.out.println(formatter.format(date));

 

        }catch(ParseException e){

               e.printStackTrace();

        }


or


         String startDateString = "20/06/2013";

        DateFormat df = new SimpleDateFormat("dd/MM/yyyy");

         Date startDate;

    try {

        startDate = df.parse(startDateString);

        String newDateString = df.format(startDate);

        System.out.println(newDateString);

    }

     catch (ParseException e)

     {

        e.printStackTrace();

    }

 

Please try above code. Hope this is helpful !!!


Regards

Vijay K


Viewing all articles
Browse latest Browse all 8851

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>