Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7794945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:55:31+00:00 2026-06-01T22:55:31+00:00

Hello I have this excerpt of code: end = new DateTime(mergeToDateTime(this.endDate, this.empEndTime)); Duration extraTime

  • 0

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)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T22:55:32+00:00Added an answer on June 1, 2026 at 10:55 pm

    I guess your instances of java.sql.Time were 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:

    System.out.println(new Time(1, 0, 0).getTime()); // Prints -7200000 in UTC+3 timezone
    

    It looks like timezone offset is introduced by JDBC driver, and it can be easily compensated by converting java.sql.Time to LocalTime (and vice versa):

    LocalTime lt = new LocalTime(time);
    

    Then you can convert LocalTime to duration:

    Duration d = new Duration(lt.getMillisOfDay());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello i have this form filling javascript: function onLine(code,nn) { document.writeform.bericht.value+=code; document.writeform.bericht.focus(); document.writeform.nickname.value+=nn; write1();
hello I have this code that use to sort a datatable. Dim sortingIndex As
Hello I currently have this code checking if a cookie exists, it works all
Hello I have this query... if (isset($_REQUEST['deletePost'])) { $q = $dbc -> prepare(DELETE FROM
Hello I have this list that i am working on. When i move the
I have this kinda template text : Hello {#Name#}, Thanks for coming blah on
Hello i have array like this [0] => Array ( [ExamMonth] => Array (
I have this string @[123:peterwateber] hello! good day! I wanna change it to <a
I have this problem when trying to run hello world program using android SDK.
Supose I have this string: a= hello world hella warld and I want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.