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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:38:06+00:00 2026-06-13T06:38:06+00:00

Assuming Brasilia GMT -0300: DST on 21/10/2012 at 00:00:00, when the clock should be

  • 0

Assuming Brasilia GMT -0300: DST on 21/10/2012 at 00:00:00, when the clock should be advanced by one hour

Java

new Date(2012 - 1900, 9, 21, 0, 0, 0)
Sun Oct 21 01:00:00 BRST 2012

Chrome/FireFox (console)

new Date(2012, 9, 21, 0, 0 ,0)
Sat Oct 20 2012 23:00:00 GMT-0300 (Hora oficial do Brasil)

The result in Java is what I was expecting, but the result in JS I can not understand. I found this post where bjornd says

This is an absolutely correct behavior

but didn’t explain why this behavior is OK.

My question is:

Why JS is returning a date one hour in the past?

P.S. I know Date is marked for “deprecation”, but I’m using GWT; Date is my only option.

  • 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-13T06:38:08+00:00Added an answer on June 13, 2026 at 6:38 am

    Basically, that answer was incorrect as far as I can see. I’m not entirely happy with the Java version, even.

    Fundamentally, you’re trying to construct a local date/time which never happened. Translating from local time to UTC is always tricky, as there are three possibilities:

    • Unambiguous mapping, which in most time zones is the case for all but two hours per year
    • Ambiguous mapping, during a backward transition, where the same local time period occurs twice (e.g. local time goes 12:59am, 1am, … 1:59am, 1am, 1:59am, 2am)
    • “Gap” mapping, where a local time period simply doesn’t exist (e.g. local time goes 12:59am, 2am, 2:01am)

    Brazil moves its clocks forward at midnight, so local time actually goes:

    October 20th 11:58pm
    October 20th 11:59pm
    October 21st 01:00am
    October 21st 01:01am
    

    The local time you’ve asked for simply never happened. It looks like Java is just assuming you want to roll it forward… whereas JavaScript is getting confused 🙁 The JavaScript result would be more understandable (but still incorrect) if you were asking for midnight at the start of February 16th 2013, for example – where the clocks would have gone back to 11pm on the 15th. 12am on the 16th is unambiguous, as it can only happen after the “second” 11pm-11:59pm on the 15th.

    A good date/time API (in my very biased view) would force you to say how you want to happen ambiguity and gaps when you do the conversion.

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

Sidebar

Related Questions

Assuming I have a table with one field called ID that stores 100 different
Assuming one table CAR with two columns CAR_ID (int) and VERSION (int) . I
Assuming I have the following list: IList<string> list = new List<string>(); list.Add(Mouse); list.Add(Dinner); list.Add(House);
Assuming Array was not overwritten, why the following comparisons output false? [] === new
Assuming a 10 element or less Object[] in Java, what would be the fastest
Assuming I am using a single threaded application, can java.util.LinkedList have a loop? I
Assuming I have the following proc: a = Proc.new do puts start yield puts
assuming below table; column name | type id | int date | varchar When
Assuming I want to get 3 documents which fit one of these attributes Class
Assuming I have the following string array: string[] str = new string[] {max, min,

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.