String time1 = "16:00:00"; String time2 = "19:00:00"; SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss"); Date date1 = format.parse(time1); Date date2 = format.parse(time2); long difference = date2.getTime() - date1.getTime();
Difference is in milliseconds.
I modified sfaizs post.
Related Posts:
- javac is not recognized as an internal or external command, operable program or batch file [closed]
- What is a StackOverflowError?
- How to uninstall Eclipse?
- How do I determine whether an array contains a particular value in Java?
- How can I solve Exception in thread “main” java.lang.NullPointerException error [duplicate]
- Why am I getting a NoClassDefFoundError in Java?
- How to avoid “ConcurrentModificationException” while removing elements from `ArrayList` while iterating it? [duplicate]
- Using Pairs or 2-tuples in Java [duplicate]
- What’s the C++ version of Java’s ArrayList
- Bad Operand Types for Binary Operator “>”?
- Error occurred during initialization of boot layer FindException: Module not found
- Why would a “java.net.ConnectException: Connection timed out” exception occur when URL is up?
- ‘mvn’ is not recognized as an internal or external command, operable program or batch file
- How to use multiple classes in java in one file?
- Java: Multiple class declarations in one file
- Why do JVM arguments start with “-D”?
- How to split a string in Java
- Printing out a linked list using toString
- Received fatal alert: handshake_failure through SSLHandshakeException
- Understanding the difference between null and ‘\u000’ in Java
- How do you make a deep copy of an object?
- what does Dead Code mean under Eclipse IDE Problems Section
- java, get set methods
- How to solve DB2 SQL Error: SQLCODE=-407, SQLSTATE=23502
- Javadoc @see or {@link}?
- Remote debugging a Java application
- What’s the difference between next() and nextLine() methods from Scanner class?
- How to identify object types in java
- What is the result of making log4j additivity equals to true or false?
- Attempt to invoke virtual method ‘…’ on a null object reference
- Is there a Mutex in Java?
- maven error: package org.junit does not exist
- ClassNotFoundException: org.slf4j.LoggerFactory
- Problems with setting the classpath in ant
- Spring Data JPA Update @Query not updating?
- how to fix EXE4J_JAVA_HOME, No JVM could be found on your system error?
- Error: ‘else’ without ‘if’
- How to create a custom exception type in Java?
- Error: JavaFX runtime components are missing, and are required to run this application with JDK 11
- Extracting .jar file with command line
- UnsatisfiedDependencyException: Error creating bean with name
- Change priorityQueue to max priorityqueue
- Only using @JsonIgnore during serialization, but not deserialization
- Cannot change version of project facet Dynamic Web Module to 3.0?
- InvalidKeyException Illegal key size
- Collections.emptyMap() vs new HashMap()
- java howto ArrayList push, pop, shift, and unshift
- Error Message: Can’t determine a valid Java Home
- How can I fix ‘android.os.NetworkOnMainThreadException’?
- java.lang.ArithmeticException: / by zero
- How can I convert a .jar to an .exe?
- How to fix “error: bad operand types for binary operator ‘||’ ” in java
- “The system cannot find the file C:\ProgramData\Oracle\Java\javapath\java.exe”
- Counting an Occurrence in an Array (Java)
- When is the finalize() method called in Java?
- Java “user.dir” property – what exactly does it mean?
- it throws me error incompatible types: unexpected return value — return 10; please correct it make note where i am doing wrong code?
- Caused by: java.security.UnrecoverableKeyException: Cannot recover key
- How can I truncate a double to only two decimal places in Java?
- How do I add a simple jQuery script to WordPress?
- I get the error int cannot be converted to boolean?c
- Can’t install JDK 9 because “Another Java installation is in progress”
- java.sql.SQLException: No database selected – why?
- Java: How to access methods from another class
- Cannot make a static reference to the non-static method fxn(int) from the type Two
- How can I check if a single character appears in a string?
- Java Error – Illegal Modifier for Parameter – Only final Permitted
- Fatal error compiling: tools.jar not found:
- Java: Increment by 2 the two inputted integer
- Sending mail error, javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 25;
- Cannot issue data manipulation statements with executeQuery()
- Why do some classes require main methods and others do not?
- java.util.IllegalFormatConversionException
- What do F and D mean at the end of numeric literals?
- Coding Conventions – Naming Enums
- Sort ArrayList of custom Objects by property
- Java better way to delete file if exists
- How do you set one array’s values to another array’s values in Java?
- ‘No JUnit tests found’ in Eclipse
- Popup Message boxes
- How to create a Multidimensional ArrayList in Java?
- what is the difference between doGet() and doPost() in term of the flow?
- Java 3D Game Engine?
- How to cast ArrayList<> from List<>
- Using insertion sort for descending order?
- What is the home directory for JDK?
- java.lang.ClassNotFoundException: org.postgresql.Driver, Android
- String index out of bounds exception java
- Javadoc @author tag good practices
- A fatal error has been detected by the Java Runtime Environment: SIGSEGV, libjvm
- java.lang.IllegalStateException: Failed to introspect Class
- ShoppingCart.Java Program Assignment
- White spaces are required between publicId and systemId
- Http status 401 This request requires HTTP authentication (). in tomcat 6
- Get integer value of the current year in Java
- How to make the division of 2 ints produce a float instead of another int?
- Java Console Prompt for ENTER input before moving on [duplicate]
- Can’t load IA 32-bit .dll on a AMD 64-bit platform
- Android Studio 2.2.3: Gradle project sync failed. Basic functionality (e.g. editting, debugging) will not work properly
- How to draw a circle with given X and Y coordinates as the middle spot of the circle?