Hello I have this excerpt of code:
end = new DateTime(mergeToDateTime(this.endDate, this.empEndTime));
Duration extraTime = new Duration(this.preTime.getTime()); //add the first 30 mins
extraTime = extraTime.plus(new Duration(this.postTime.getTime())); //add the second 30 mins
end = end.plus(extraTime); // extraTime = -3600?
When I look in the debugger my durations are always coming up negative. I have no idea why this is, even though according to the API, it is possible to create a duration out of the a long type, hence the getTime(). (preTime and postTime are java.sql.Time types)
I guess your instances of
java.sql.Timewere created in such a way that their millisecond values include timezone offset.For example, deprecated
java.sql.Time(int hour, int minute, int second)constructor takes offset of the current timezone into account:It looks like timezone offset is introduced by JDBC driver, and it can be easily compensated by converting
java.sql.TimetoLocalTime(and vice versa):Then you can convert
LocalTimeto duration: