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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:25:13+00:00 2026-06-15T14:25:13+00:00

I am developing a Java Swing application which sends a report on a specific

  • 0

I am developing a Java Swing application which sends a report on a specific day and time of a week, say for example the report time is Wed 09:00:00. I am trying to calculate the time difference between current Day and time with report Time. For example:

DayTime1 = “Wed 09:00:00”
DayTime2 = “Tue 13:00:00”

How do I calculate the time difference between these two values? I tried by myself, but I couldn’t even get close to the result.

  • 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-15T14:25:14+00:00Added an answer on June 15, 2026 at 2:25 pm

    You need to create the String into Date objects and then calculate the duration between the two instances.

    DateFormat dateformat = new SimpleDateFormat("EEE HH:mm:ss");
    Date date1 = dateformat.parse(dayTime1);
    Date date2 = dateformat.parse(dayTime2);
    getDuration(date1, date2, Calendar.MINUTE);
    
    public static long getDuration(Date returnTime, Date leaveTime, int scale) {
            long durationInMillis = returnTime.getTime() - leaveTime.getTime();
            switch (scale) {
                case Calendar.MINUTE:
                    return durationInMillis / ONE_MINUTE_IN_MILLIS;
                case Calendar.MILLISECOND:
                    return durationInMillis;
                case Calendar.SECOND:
                    return durationInMillis / ONE_SECOND_IN_MILLIS;
                case Calendar.HOUR:
                    return durationInMillis / ONE_HOUR_IN_MILLIS;
                case Calendar.DAY_OF_YEAR:
                case Calendar.DATE:
                    return durationInMillis / ONE_DAY_IN_MILLIS;
            }
            throw new IllegalArgumentException("invalid scale specified");
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing a Java Swing application which contains a JTable . By default, while
I'm trying myself developing a desktop application with Java and Java Swing. Currently I'm
I'm developing a console Java application(Not swing) using java.awt.Desktop class, which will launch the
I'm developing a java application which will run on LAN, i do test today
Developing a desktop application based on Java + Swing I faced the problem of
I am developing a Java Desktop Application with GUI implemented in SWING. I hava
I am developing a Java desktop application and I use Swing to build the
I'm debeloping a Java Swing application, which persists the information through Hibernate, currently using
I'm developing a Desktop Application in java(jdk 1.6) with swing but having a problem
I am new to Java and am developing a java swing application. The main

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.