I have a problem, I'm trying to save a date in oracle with the formatted dd/MM/yyyy
, however, in the database it displays the date in dd/MM/yy
format.
So, I came to doubt, if the type I used in the table is not appropriate, or if the date I move to the bank that is wrong.
In my DAO (in java), to include the date, I convert it with the following methods:
public static java.sql.Date converteParaBanco(Date data) {
return new java.sql.Date(data.getTime());
}
public static Date converteDoBanco(java.sql.Date data) {
return new Date(data.getTime());
}
Applying the method in DAO:
ps.setDate(5, ConverteData.converteParaBanco(pojoCompra.getDataCompra()));
Given a system.out in the above line, I realized that my method makes the date stay in 2017-09-22
format.
My attribute in the database is of type DATE
.
What could I do to have the date saved and also returned in the form of dd/MM/yyyy
?