简体   繁体   中英

Store Date in Oracle database

I have a POJO named Employee.Java who has an instance variable, lets call it birthdate. I have it's type mentioned as java.util.Date and it's corresponding column type in Oracle table is DATE.

Employee.Java

Class Employee{
 private java.util.Date birthDate;
}


Table
create table Employee(birthDate DATE);

I have another class which takes an instance of Employee class and saves it to database. Since the type of birthdate column is DATE, it will be stored in the default format DD-MON-YY in table.

I need to store the birthDate value in database in the format YYYY-MM-DD with java.util.Date typed instance variable. How can I achieve this task. Kindly assist me.

The date in database has no specific format. You shouldn't interfere with how Oracle stores the date. However, you can use PLSQL's to_date and to_char functions to format the value if you want to read the data back in a specific format.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM