There are a lot of misconceptions in the question:
I have DATETIME
Oracle does not have a DATETIME
data type - it has DATE
or TIMESTAMP
both of which have a time component.
set as DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
A DATE
(or TIMESTAMP
) column does not have a format; Oracle stores DATE
data types as 7-bytes (and similar for TIMESTAMP data types) and it is not until it is passed to a client program (i.e. SQL/Plus, SQL Developer, Toad, Java, Python, etc) and that client program formats it according to whatever rules it has that the date gets a format.
The default string format for dates in SQL/Plus or SQL Developer is set by the NLS_DATE_FORMAT
session parameter. Other clients will typically have parameters that you can set for the default date format (if they don't also use the NLS settings). However, beware that the NLS_DATE_FORMAT
is a session parameter so it belongs to the user's session and multiple users can each have a different value for the parameter corresponding to how they have set it.
If you have overridden the default date format settings in the SQL Developer IDE then you can change it in "Tools" > "Preferences" > "Database" > "NLS".
For DD:MM:YYYY HH:MM
it runs successfully.
The format model MM
(and mm
as it is not case sensitive) is for month and HH
is a 12-hour clock so you are specifying:
day:month:year hours-on-12-hour-clock:month
If you want to give a date a specific format then you will need to convert it to a string:
SELECT TO_CHAR( SYSDATE, 'MM/DD/YYYY HH24:MI' )
FROM DUAL;
or if you want to convert a string to a date then use:
SELECT TO_DATE( your_string, 'MM/DD/YYYY HH24:MI' )
FROM DUAL;
Also in some cases while creating CSV, the date field gets missed.
It probably is not missed - it is probably just NULL
and gets formatted as an empty string.