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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:17:18+00:00 2026-05-18T02:17:18+00:00

I am getting a date/time string from web in the format of "yyyy/mm/dd’T’HH:MM:SS’Z’" and

  • 0

I am getting a date/time string from web in the format of "yyyy/mm/dd’T’HH:MM:SS’Z’" and it is in UTC.

Now I have to identify the current time zone of device and then convert this time to my local time..

How do I do it?

(FYI, Currently, UTC time is 10:25 AM, in India current time is 3:55 PM)

  • 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-18T02:17:19+00:00Added an answer on May 18, 2026 at 2:17 am

    Try using TimeZone.getDefault() instead of TimeZone.getTimeZone("GMT")

    From the docs:

    … you get a TimeZone using
    getDefault which creates a TimeZone
    based on the time zone where the
    program is running.

    EDIT: You can parse date using SimpleDateFormat (there is also the documentation on the format string there). In your case, you want to do (untested):

     // note that I modified the format string slightly
     SimpleDateFormat fmt = new SimpleDateFormat("yyyy/MM/dd'T'HH:mm:ss'Z'");
     // set the timezone to the original date string's timezone
     fmt.setTimeZone(TimeZone.getTimeZone("GMT"));
     Date date = fmt.parse("1998/12/21T13:29:31Z", new ParsePosition(0));
    
     // then reset to the target date string's (local) timezone
     fmt.setTimeZone(TimeZone.getDefault());
     String localTime = fmt.format(date);
    

    alternatively, use two separate instances of SimpleDateFormat, one for original and one for target time.

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

Sidebar

Related Questions

Basically, I'm getting a date time string from an API, and I want to
I'm getting from my webapp date and time in format: 2012-02-23T23:25:22Z I tried with
I am getting the error Conversion failed when converting date and/or time from character
I'm getting the time via php $current_hour = date(G); Now let's say the $current_hour
I'm getting a date from a string, parsing it to get the day, month
Possible Duplicate: Parse string to DateTime in C# I am getting date and time
I have a string which returns the date and time as 2012-11-08 12:45:30 .
I parse time from string in format HH:mm with java.text.SimpleDateFormat . For example 10:30
Hi I am getting an error 'Conversion failed when converting date and/or time from
I'm getting a string from the database and converting it into a time, eg

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.