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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:33:45+00:00 2026-06-18T05:33:45+00:00

I am creating a Java GUI on a clock which asks the user to

  • 0

I am creating a Java GUI on a clock which asks the user to change the time from current time. I have the system time and the user time. What should be the code so that the user time gets displayed. The foolowing code i am using :

        Date curDate = new Date();
        //changeTime i have got from the user
        double time=0;
        if(curDate.getTime()- changeTime.getTime() > 0){
            time = curDate.getTime() - changeTime.getTime();
            time = time/(1000);
        }
        else{
            time = changeTime.getTime()-curDate.getTime();
            time = time/(1000);
        }
        if(changeTime.getHours()==0 && changeTime.getMinutes()==0){
            time=0;
        }
        curDate.setHours(curDate.getHours()+(int)time/(3600));
        curDate.setMinutes(curDate.getMinutes()+((int)time/60)%60);
  • 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-18T05:33:47+00:00Added an answer on June 18, 2026 at 5:33 am

    A new Date() is “intended to reflect coordinated universal time (UTC).” What the user sees on the clock depends on the TimeZone, which can be specified in the DateFormat used to render the date. The example below prints the same instant in GMT and a selection of time zones from New York to Berlin.

    Addendum: I find it helpful to think of Date as a model and DateFormat as a view of that model.

    03-Feb-2013 18:01:42 GMT GMT 1359914502673
    03-Feb-2013 13:01:42 EST America/New_York 1359914502673
    03-Feb-2013 14:01:42 AST America/Aruba 1359914502673
    03-Feb-2013 15:01:42 ART America/Buenos_Aires 1359914502673
    03-Feb-2013 16:01:42 BRST America/Sao_Paulo 1359914502673
    03-Feb-2013 17:01:42 AZOT Atlantic/Azores 1359914502673
    03-Feb-2013 18:01:42 GMT Europe/London 1359914502673
    03-Feb-2013 19:01:42 CET Europe/Berlin 1359914502673
    

    package date;

    import java.text.DateFormat;
    import java.text.SimpleDateFormat;
    import java.util.Date;
    import java.util.TimeZone;
    
    /** @see http://stackoverflow.com/a/14675418/230513 */
    public class TestSDF {
    
        private static final String s = "dd-MMM-yyyy HH:mm:ss zz";
        private static final DateFormat f = new SimpleDateFormat(s);
    
        public static void main(String[] args) {
            Date date = new Date();
            print("GMT", date);
            print("America/New_York", date);
            print("America/Aruba", date);
            print("America/Buenos_Aires", date);
            print("America/Sao_Paulo", date);
            print("Atlantic/Azores", date);
            print("Europe/London", date);
            print("Europe/Berlin", date);
        }
    
        private static void print(String tz, Date d) {
            f.setTimeZone(TimeZone.getTimeZone(tz));
            System.out.println(f.format(d)
                + " " + tz
                + " " + d.getTime());
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating an GUI application in java that uses input from the user
i am creating a java application which is will be GUI for a bash
I am creating one GUI in swing Java. I have to use one button
I am creating a GUI using Java. This GUI launches a program from the
I have a question about GUI design, specifically with Java Swing and creating clean
For a GUI application I am creating in Java, I have the following: A
I'm creating a Java application in NetBeans, and I have the following code that
I'm creating a Java swing GUI and I have formatted a JPanel to use
Just wondering what the opposing framework in Java would be for creating modular GUI
I've creating a Java Swing application and I realized that I have many many

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.