Linked Questions
15 questions linked to/from In Java, how do I get the difference in seconds between 2 dates?
-3 votes
2 answers
11k views
How to find out seconds between two dates in java [duplicate]
Possible Duplicate: In Java, how do I get the difference in seconds between 2 dates? Hi i have two dates as follows 1970-01-01 and 2011-08-01 which are in yyyy-mm-dd format. How to find out the ...
1 vote
1 answer
2k views
How to subtract dates using java.sql.Timestamp [duplicate]
I am practically checking how much time taking by collection(s) insertion with 'N' elements, Now I am stuck in checking total time taken by ArrayList in Insertion process. Timestamp startTimeStamp =...
-1 votes
1 answer
91 views
Java get the number of seconds between 2 dates [duplicate]
I'm trting to send data every 10 seconds , so I'm trying tp use this code I wrote but I think I made a mistake in the converting to seconds? Calendar Time= Calendar.getInstance(); Calendar SendDate=...
-2 votes
1 answer
103 views
Finding the difference between dates in seconds using java [duplicate]
I'm stuck between java.time.temporal.ChronoUnit and java.time.temporal.Temporal until. How do they work??
0 votes
0 answers
63 views
Calculate time difference in minutes given specific date and time [duplicate]
How would I calculate the time difference in minutes from the current time against a date/time in the format of "August 3, 2021 at 4:29 PM"?
411 votes
12 answers
530k views
Java 8: Difference between two LocalDateTime in multiple units
I am trying to calculate the difference between two LocalDateTime. The output needs to be of the format y years m months d days h hours m minutes s seconds. Here is what I have written: import java....
235 votes
3 answers
44k views
How to use ThreeTenABP in Android Project
I'm using Android Studio 2.1.2 and my Java setup is the following: >java -version > openjdk version "1.8.0_91" > OpenJDK Runtime Environment (build 1.8.0_91-8u91-b14-3ubuntu1~15.10....
10 votes
4 answers
14k views
How to calculate the time difference between two events in Java?
I want to calculate time difference in seconds between to time instants. For example, during execution of the program, I set the value of a variable and after some time I change it again. What was the ...
4 votes
5 answers
3k views
How can I measure time in Java not susceptible to System clock changes?
I would like to measure elapsed time in a Java. However differences in System.currentTimeMillis() and (I believe) System.nanoTime() can be changed by external changes eg someone (or the system) ...
-5 votes
3 answers
10k views
Time difference program
I am using following function to calculate time difference. It is not showing proper output. After 1 month time difference it is showing 2 minutes difference. What is wrong with my program? public ...
2 votes
2 answers
3k views
Java jsr310: difference between dates and times
There are a plethora of SO questions that deal with calculating the difference between two dates or two times in Java. Many answers point out the problems with the core Java Date classes, and suggest ...
1 vote
2 answers
4k views
Subtract 2 timestamps and check their difference
I want to find difference between 2 timestamps. What I am doing is storing 1st timestamp in shared prefs and try to subtractt it from the new timestamp. To get timestamp, I am using - public static ...
1 vote
2 answers
2k views
Converting Time & Date to relative time (CSV processing)
I am currently in the early stages of writing a multi-faceted investment algorithm. The part I am currently working on is concerned with using a Graphical Gaussian Model with a LASSO penalty to find ...
-4 votes
2 answers
4k views
how to convert date to seconds in java
I have a date column in postgres db whose value is 2018-11-20 22:07:20. The datatype is timestamz. I want to get the above value in java code and convert that to seconds with respect to the current ...
0 votes
3 answers
745 views
Trying to take two timestamps, subtract them, convert the difference to seconds and store in an int variable
I'm having trouble understanding getting timestamps, subtracting them, and being able to assign and use the difference in future calculations. I am using Java in Android Studio. When I use ...