user1742913
user1742913

Reputation: 1

save current date in custom format to oracle Db

I want to save date ie.current date in oracle DB in MM/dd/yyyy format.

My oracle db has column , which has data type as date.

can anybody let me know how I can do this. I tried like,

java.text.DateFormat df = new SimpleDateFormat("MM/dd/yyyy"); 
String s = df.format(new Date());  // It is giving in String format

But How I can set it to my oracle DB column ?

Upvotes: 0

Views: 598

Answers (1)

Pradeep Pati
Pradeep Pati

Reputation: 5919

Just save the date without any formatting.

update table set column=sysdate where id=1

While reading back the data, use

select to_char(column, 'MM/DD/YYYY') my_date from table

Upvotes: 1

Related Questions