2

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
  • 168,305
  • 31
  • 280
  • 331
ramkumar
  • 31
  • 1
  • 1
  • 2

2 Answers2

3

Use Date format as dd-MMM-yyyy

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

Shows output as

10-jul-1992
Houssam Badri
  • 2,441
  • 3
  • 29
  • 60
Naveen Kumar Alone
  • 7,536
  • 5
  • 36
  • 57
1

Can you try

Date d = new SimpleDateFormat("dd/MMM/yyyy").parse(date);
Reji
  • 3,426
  • 2
  • 21
  • 25