There is Java code,which is ran on 2 different environments and inserts records with JdbcTemplate
to DB.
Results of its running are different for both envs. Particularly,for Date
fields.
On first environment(Oracle XE) it produces record:
"12/03/2010";191094;"71697211000";3229;880323202;NULL;0;1;0;NULL;0;NULL
Second environment(Oracle non XE):
"12/03/2010 12:00:00";191094;"71697211000";3229;880323202;NULL;0;1;0;NULL;0;NULL
NLS_DATE_FORMAT(if it's crucial) for first env is DD-MON-RR
,
for second env is DD-MON-RRRR
The question is,what Oracle settings may affect,that second env Date format is another?
Calendar. clear(field) Reset the value of field to undefined. field : Required Calendar field, Year, month , date, hour , minute , second , millseconds. The method isSet() returns true or false based on the value set for the field or not.
Java Calendar setTime() MethodThe setTime () method of java. util. Calendar class is used to set the Time of current calendar object. A Date object id is passed as the parameter into this method.
The getInstance() method in Calendar class is used to get a calendar using the current time zone and locale of the system. Syntax: public static Calendar getInstance() Parameters: The method does not take any parameters. Return Value: The method returns the calendar.
You can format the calender date object when you want to display and keep that as a string.
should set following Calendar properties in Java code:
Calendar cal = Calendar.getInstance();
cal.set(Calendar.HOUR_OF_DAY, cal.getActualMinimum(Calendar.HOUR_OF_DAY));
cal.set(Calendar.MINUTE, cal.getActualMinimum(Calendar.MINUTE));
cal.set(Calendar.SECOND, cal.getActualMinimum(Calendar.SECOND));
cal.set(Calendar.MILLISECOND, cal.getActualMinimum(Calendar.MILLISECOND));
instead of:
Calendar cal = Calendar.getInstance();
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With