[
https://issues.apache.org/jira/browse/DERBY-1816?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12494102
]
A B commented on DERBY-1816:
----------------------------
"assertGetWithCal()" as referenced in previous comment (forgot to paste):
----
private void assertGetWithCal(ResultSet rs) throws Exception
{
Calendar targetCal =
Calendar.getInstance(java.util.TimeZone.getTimeZone("GMT-10:00"));
targetCal.set(2010, Calendar.OCTOBER, 10, 10, 10, 10);
System.out.println(" targetBefore -=> " + printCalendar(targetCal));
Timestamp tsv = rs.getTimestamp(1, targetCal);
Calendar getCal = Calendar.getInstance();
getCal.setTime(tsv);
// System.out.println(" got ts -=> " + tsv + " (" +
tsv.getTimezoneOffset() + ")");
System.out.println(" got cal -=> " + printCalendar(getCal));
System.out.println(" targetAfter -=> " + printCalendar(targetCal) +
"\n");
return;
}
private String printCalendar(Calendar cal)
{
StringBuffer sbuf = new StringBuffer();
sbuf.append(cal.get(Calendar.MONTH) + " ");
sbuf.append(cal.get(Calendar.DAY_OF_MONTH) + ", ");
sbuf.append(cal.get(Calendar.YEAR) + " -- ");
sbuf.append(cal.get(Calendar.HOUR_OF_DAY) + ":");
sbuf.append(cal.get(Calendar.MINUTE) + ":");
sbuf.append(cal.get(Calendar.SECOND) + ".");
sbuf.append(cal.get(Calendar.MILLISECOND));
sbuf.append(" (" + cal.getTimeZone().getID() + ")");
return sbuf.toString();
}
> Client's ResultSet.getTime() on a SQL TIMESTAMP column loses the sub-second
> resolution and always has a milli-second value of zero.
> -----------------------------------------------------------------------------------------------------------------------------------
>
> Key: DERBY-1816
> URL: https://issues.apache.org/jira/browse/DERBY-1816
> Project: Derby
> Issue Type: Bug
> Components: JDBC, Network Client
> Affects Versions: 10.1.1.0, 10.1.2.1, 10.1.3.1, 10.2.1.6, 10.3.0.0
> Reporter: Daniel John Debrunner
> Assigned To: A B
> Priority: Minor
> Attachments: d1816_recycleCleanup_v1.patch
>
>
> In embedded the java.sql.Time object returned from ResultSet.getTime() for a
> SQL TIMESTAMP object has its millisecond value for the time portion equal to
> that for the java.sql.Timestamp value.
> In client the millisecond time value for such a value is always set to zero.
> Note a Derby SQL TIME value has by definition resolution of only a second so
> its millisecond value is always zero,
> but java.sql.Time is not a direct mapping to the SQL Type, it's a JDBC type,
> so when converting from a SQL TIMESTAMP
> it should retain the precision.
> The new test lang.TimeHandlingTest has this assert code that shows the
> problem, one of its calls will be commented out
> with a comment with this bug number.
> private void assertTimeEqual(Time tv, Timestamp tsv)
> {
> cal.clear();
> cal.setTime(tv);
>
> int hour = cal.get(Calendar.HOUR_OF_DAY);
> int min = cal.get(Calendar.MINUTE);
> int sec = cal.get(Calendar.SECOND);
> int ms = cal.get(Calendar.MILLISECOND);
>
> // Check the time portion is set to the same as tv
> cal.clear();
> cal.setTime(tsv);
> assertEquals(hour, cal.get(Calendar.HOUR_OF_DAY));
> assertEquals(min, cal.get(Calendar.MINUTE));
> assertEquals(sec, cal.get(Calendar.SECOND));
> assertEquals(ms, cal.get(Calendar.MILLISECOND)); <<<<<<<<<<<<<
> FAILS HERE
> }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.