-2

i have problem of parsing a String into Date when the month contains 3 letters instead of two

user3505689
  • 97
  • 1
  • 1
  • 10

3 Answers3

4

use DateFormat in this way:

DateFormat df = new SimpleDateFormat("dd-MMM-yyyy");
System.out.println( df.parse("20-Feb-2006"));
Jens
  • 63,364
  • 15
  • 92
  • 104
1

USe

    String strDate = "20-Feb-2006";
    SimpleDateFormat formatter = new SimpleDateFormat("dd-MMM-yyyy");
    Date dateStr = formatter.parse(strDate);
Cris
  • 12,059
  • 5
  • 34
  • 50
1
DateFormat df = new SimpleDateFormat("dd-MMM-yyyy", Locale.ENGLISH);
Date date = df.parse("20-Feb-2006");
SparkOn
  • 8,543
  • 4
  • 27
  • 30