Guest User

Untitled

a guest
Nov 16th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.54 KB | None | 0 0
  1. public static double getTimeDifference(String time1, String time2) throws ParseException {
  2.         long epoch1 =   getEpoch(time1);
  3.         long epoch2 =   getEpoch(time2);
  4.         double diff =   Math.abs(Math.floor((epoch1 - epoch2)/60));
  5.        
  6.         return diff;
  7.     }
  8.    
  9.     public static long getEpoch(String time1) {
  10.         time1           =   time1.trim();  
  11.         long epoch      =   0;
  12.         try {
  13.             epoch   =   new java.text.SimpleDateFormat ("EEE, dd MMM yyyy HH:mm:ss Z").parse(time1).getTime();
  14.             epoch   =   epoch/1000;
  15.         } catch (ParseException e) {
  16.             e.printStackTrace();
  17.         }
  18.         return epoch;
  19.     }
Add Comment
Please, Sign In to add comment