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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:08:30+00:00 2026-06-14T08:08:30+00:00

private String target_time_zone = Australia/Hobart; private String format = MM/dd/yyyy HH:mm:ss z; public static

  • 0
  private String target_time_zone = "Australia/Hobart";
  private String format    = "MM/dd/yyyy HH:mm:ss z";


  public static void main(String args[]) throws ParseException {

        Date date = Calendar.getInstance().getTime();
        TZFormat tzFormat = new TZFormat();
        System.out.println("Converted TZ Date: "+ tzFormat.TZF(date));



  }

  public Date TZF(Date dt) throws ParseException {

        TimeZone tz = TimeZone.getTimeZone(target_time_zone);     
        SimpleDateFormat date_format_gmt = new SimpleDateFormat(format);
        date_format_gmt.setTimeZone(tz);
        SimpleDateFormat date_format_gmt1 = new SimpleDateFormat(format);
        date_format_gmt1.setTimeZone(tz);

        System.out.println("formated value: "+ date_format_gmt.format(dt));


       return date_format_gmt1.parse(date_format_gmt.format(dt));
  }

OUTPUT:

formated value: 11/15/2012 03:16:11 EST
Converted TZ Date: Wed Nov 14 21:46:11 IST 2012

Actually my requirement is i want to convert the date to the target_time_zone timeZone with the format and return back the converted Date.

 private String target_time_zone = "Australia/Hobart";
 private String format     = "MM/dd/yyyy HH:mm:ss z";

here want happens is in TZF method formated date_format_gmt.format(dt) is formated the date to my given TimeZone when we parse that value it is showing previous value (actual time).

how to get the Date object with selected Time Zone.

  • 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-14T08:08:31+00:00Added an answer on June 14, 2026 at 8:08 am

    Date object always represents time in milliseconds (epoch time), it doesn’t contain any timezone information. When you format and make it as String, then only it prints in required format with specified timezone.

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

Sidebar

Related Questions

private String message = ; public String getMessage() { return message; } public void
I have the following code: private String foo; public void setFoo(String bar) { foo
Consider this simple example - public class Person { private String name; private Date
private String setDate(int day) { Calendar cal = Calendar.getInstance(); cal.setTime(new Date()); cal.add(Calendar.DATE, + day);
private string _itemId; [Browsable(true), Description(Required identifier for the Item.)] public string ItemId { get
@Entity public class Blobx { private String name; private BlobKey blobKey; @Id @GeneratedValue(strategy =
private static class FilterByStringContains implements Predicate<String> { private String filterString; private FilterByStringContains(final String filterString)
private void Abc() { string first=; ArrayList result = new ArrayList(); ArrayList secResult =
Consider the following ViewModel property: private string _slowProperty; public string SlowProperty { get {
Consider the following line: readonly private string TARGET_BTN_IMG_URL = @\\ad1-sunglim\Test\; In this line, why

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.