-2

what is the format in SimpleDateFormat for parsing a string ie 07/12/2013 into a date type? I am using the following code, but desired format is not comimg.

SimpleDateFormat formatter ; 
Date notBeforeDate ,notAfterDate; 
formatter = new SimpleDateFormat("DD/MM/YYYY");
notBeforeDate = (Date)formatter.parse(notBeforeValue);  
notAfterDate = (Date)formatter.parse(notAfterValue);  
ssindelar
  • 2,833
  • 1
  • 17
  • 36
user2541475
  • 7
  • 1
  • 4
  • 2
    possible duplicate of [Java string to date conversion](http://stackoverflow.com/questions/4216745/java-string-to-date-conversion) – Shashi Jul 31 '13 at 06:36

2 Answers2

2

Assuming you are looking for a Java solution. Change the format string :

DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
Date date = formatter.parse("07/12/2013");

Refer the documentation for the exact format string information.

AllTooSir
  • 48,828
  • 16
  • 130
  • 164
1

Try this :

SimpleDateFormat formatter=new SimpleDateFormat("dd/MM/yyyy"); ; 
Date notBeforeDate ,notAfterDate; 
notBeforeDate =formatter.parse("Your String format Date");  
notAfterDate =formatter.parse("Your String format Date"); 

Read More. Hope it will help you.

JDGuide
  • 6,239
  • 12
  • 46
  • 64