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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:10:12+00:00 2026-06-14T20:10:12+00:00

The following code cannot pass the assertion under the Android emulator: TimeZone timezone =

  • 0

The following code cannot pass the assertion under the Android emulator:

TimeZone timezone = TimeZone.getTimeZone("Hongkong");
Locale locale = new Locale("zh", "HK"); 
Calendar calendar = Calendar.getInstance(timezone, locale);

calendar.set(Calendar.YEAR, 1979);
calendar.set(Calendar.MONTH, 4);        
calendar.set(Calendar.DAY_OF_MONTH, 13);            
calendar.set(Calendar.HOUR_OF_DAY, 4);  
calendar.set(Calendar.MINUTE, 30);      
calendar.set(Calendar.SECOND, 0);        

DateFormat df = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);
df.setTimeZone(timezone);
String sDate = df.format(calendar.getTime());

int debug = calendar.get(Calendar.HOUR_OF_DAY);
Assert.assertEquals("Error datetime: " + sDate, 4, debug);

And I found that, if change the DAY_OF_MONTH to 12, the error is gone:
calendar.set(Calendar.DAY_OF_MONTH, 12);

Note that this problem is not exists on JUnit test. (without Android)

Finally, this problem seems may not be exists on Android real machine.

Any comments?

  • 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-14T20:10:13+00:00Added an answer on June 14, 2026 at 8:10 pm

    I believe, it’s because of this transition:

    Hong Kong adopted daylight saving measures in 1941. However, in the 1970s, the government found these measures unnecessary as Hong Kong is at a relatively low latitude. The practice was eliminated in 1979.

    Here is the DST change which happened on 13th May 1979.

    Sunday, May 13, 1979 3:29:59 AM No UTC+8h HKT

    3:30:00 AM → 4:30:00 AM +1h UTC+9h HKST DST starts

    Sunday, October 21, 1979 3:29:59 AM +1h UTC+9h HKST

    Since DST for Hong Kong went ON and OFF and finally OFF, it may be the root cause of the issue.

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

Sidebar

Related Questions

The following code runs fine under Magento 1.6 but raises a Mage_Core_Exception (message: 'Cannot
Basically it is the following code, which cannot pass compiler (g++) #include <boost/program_options.hpp> #include
I'm using following code but cannot return data from MySQL. This is the output:
The following code when compiled give this error I cannot understand why this is
The following code throws an compile-time error like Cannot convert type 'string' to 'int'
In following code the issue is, that I cannot test dao.add() without using dao.list().size()
The following code does not compile, saying error C2248: 'A::getMe' : cannot access private
When running the following code I get no output but I cannot work out
I have the following code in html, I cannot get the Function call back
I'm using following code but cannot return data from MySQL. This is the output:

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.