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

  • Home
  • SEARCH
  • 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 8312129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:03:29+00:00 2026-06-08T20:03:29+00:00

I am working on a desktop application. It would get input as a text

  • 0

I am working on a desktop application. It would get input as a text file from user having contents like this :

..................................   
..................................

Mon Jul  9 14:41:07 MDT 2012
..................................
..................................
..................................

I am using this information and creating a timeseries chart using jfreechart library. Timezone could be anything available in the world. But when I use this file its default timezone is sytem’s timezone(IST) so doesn’t show MDT time. When I tried to capture timezone from date and then used

TimeZone.setDefault(TimeZone.getTimeZone("MDT"));

It didn’t work. How can I change the default timezone in Java when I am having abbreviation for timezone like MDT, CDT etc?

  • 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-08T20:03:30+00:00Added an answer on June 8, 2026 at 8:03 pm

    Thanks Guys. Thanks for quick responses. @vikas your response proves to be more useful. I am using following code and it worked well.

    String timezoneLongName = "";
    
    String fileTimeZone     = "MDT"; //timezone could be anything, getting from file.
    
    Date date            = new Date();
    String TimeZoneIds[] = TimeZone.getAvailableIDs();
    
    for (int i = 0; i < TimeZoneIds.length; i++) {
    
        TimeZone tz   = TimeZone.getTimeZone(TimeZoneIds[i]);
        String tzName = tz.getDisplayName(tz.inDaylightTime(date),TimeZone.SHORT);
    
        if(fileTimeZone.equals(tzName)){
            timezoneLongName = TimeZoneIds[i];
            break;
        }
    }
    
    if(timezoneLongName != null && !timezoneLongName.isEmpty() && !timezoneLongName.trim().isEmpty() && timezoneLongName.length() != 0){
        TimeZone.setDefault(TimeZone.getTimeZone(timezoneLongName));
    } 
    

    Although there are more than one entries for “MDT” timezone but it resolves my problem without any problem at first match itself. I have tested code on CDT, MDT and CDT timezones and it worked really well.Thanks Guys!!!

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

Sidebar

Related Questions

I am working on a Prism desktop application and would like to know the
I am working on a simple desktop java application. I would like to make
I would like to implement Aero Peek of tabs in my desktop application (as
I'm working on a desktop application and would love to use any hardware random
I'm working on a desktop application for OS X using Ruby-Tk, and I would
I am working on a simple standalone desktop application which would generate report based
I'm working on a desktop application that will produce several in-memory datasets as an
im trying to create offline desktop application. everything is working fine. The only problem
I'm working on converting a very simple java desktop application to run in java
I'm currently working on a project that is building a java-based desktop application 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.