1

i am having string as 10-07-1992. i have to convert this to oracle date format like 10-jul-1992. i tried using this

String date = fqu.getDob();

Date d = new SimpleDateFormat("dd/MM/yyyy").parse(date);

java.sql.Date sqlDate = new java.sql.Date(d.getTime());

System.out.println("sql date"+sqlDate);

this prints like 1992-07-10. but this is not recognized while inserting this value in oracle.

i dont need to_cast method. this works only in sql command prompt. i want to do this conversion inside java file.

Rahul Tripathi
  • 161,154
  • 30
  • 262
  • 319
ramkumar
  • 21
  • 1
  • 1
  • 2

2 Answers2

2

Use Date format as dd-MMM-yyyy

Date d = new SimpleDateFormat("dd-MMM-yyyy").parse(date);

Shows output as

10-jul-1992
Houssem Badri
  • 2,273
  • 3
  • 28
  • 55
Naveen Kumar Alone
  • 7,360
  • 5
  • 34
  • 53
1

Can you try

Date d = new SimpleDateFormat("dd/MMM/yyyy").parse(date);
Reji
  • 3,248
  • 2
  • 20
  • 24