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 6728119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:07:52+00:00 2026-05-26T10:07:52+00:00

I thought 2011-10-23 12:00:00 would remain the same as UTC and that the Converted

  • 0

I thought 2011-10-23 12:00:00 would remain the same as UTC and that the Converted date would be 2011-10-23 17:00:00.

DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date dt = formatter.parse("2011-10-23 12:00:00");
LocalDateTime ldt = new DateTime(dt).withZone(DateTimeZone.UTC).toLocalDateTime();
LOGGER.warn("Original date: " + ldt.toDateTime().toDate().toString());
DateTime cvtldt = ldt.toDateTime(DateTimeZone.forID("-05:00"));
LOGGER.warn("Converted date: " + cvtldt.toLocalDateTime().toDateTime().toDate().toString());

I don’t understand why the output is minus one hour?

Original date: Sun Oct 23 11:00:00 BST 2011
Converted date: Sun Oct 23 11:00:00 BST 2011    
  • 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-05-26T10:07:52+00:00Added an answer on May 26, 2026 at 10:07 am

    You’re using Date.toString() which always uses the local time zone. See how your string contains “BST”?

    Ideally, stick to just Joda Time for as much of the time as you can:

    • Parse with the Joda Time formatters
    • Don’t convert back to Date unless you need to
    • Don’t use Date.toString() if you can possibly avoid it; you have no control over its format.

    It’s not clear what you’re really trying to achieve, but you almost certainly don’t want to do this many conversions. For example, you’re calling toLocalDateTime() followed by toDateTime() again – which means it’s using the system default time zone, after you’d carefully specified UTC in the previous conversion…

    Your code contains the following conversions (in this order):

    • String to Date
    • Date to DateTime
    • DateTime to DateTime in UTC
    • DateTime to LocalDateTime (*)
    • LocalDateTime to DateTime
    • DateTime to Date
    • Date to String
    • (From the results at *) LocalDateTime to DateTime
    • DateTime to LocalDateTime
    • LocalDateTime to DateTime
    • DateTime to Date
    • Date to String

    What do you think the chances of all those conversions being both necessary and correctly specified are? 😉

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am brand new to game development and I thought it would be fun
I thought I heard that py2exe was able to do this, but I never
I thought that there was some way in .net 3.0 to give an array
I thought I'd offer this softball to whomever would like to hit it out
I thought people would be working on little code projects together, but I don't
I want to store a blog post in a database. I thought it would
I just came across something that I have not seen before and I thought
I thought this would be simple, but I'm struggling (might be Friday brains) I
I`m a JavaScript/programming newbie trying to figure out the new bookmarklet that's been released
I've stumbled onto an issue I thought would be easy to resolve, but seems

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.