Android difference between Two Dates

DateTimeUtils obj = new DateTimeUtils(); SimpleDateFormat simpleDateFormat = new SimpleDateFormat(“dd/M/yyyy hh:mm:ss”); try { Date date1 = simpleDateFormat.parse(“10/10/2013 11:30:10”); Date date2 = simpleDateFormat.parse(“13/10/2013 20:35:55”); obj.printDifference(date1, date2); } catch (ParseException e) { e.printStackTrace(); } //1 minute = 60 seconds //1 hour = 60 x 60 = 3600 //1 day = 3600 x 24 = 86400 public void … Read more

Differences between Oracle JDK and OpenJDK

Both OpenJDK and Oracle JDK are created and maintained currently by Oracle only. OpenJDK and Oracle JDK are implementations of the same Java specification passed the TCK (Java Technology Certification Kit). Most of the vendors of JDK are written on top of OpenJDK by doing a few tweaks to [mostly to replace licensed proprietary parts … Read more

Get the time difference between two datetimes

This approach will work ONLY when the total duration is less than 24 hours: var now = “04/09/2013 15:00:00”; var then = “04/09/2013 14:20:30″; moment.utc(moment(now,”DD/MM/YYYY HH:mm:ss”).diff(moment(then,”DD/MM/YYYY HH:mm:ss”))).format(“HH:mm:ss”) // outputs: “00:39:30” If you have 24 hours or more, the hours will reset to zero with the above approach, so it is not ideal. If you want … Read more

What is the difference between size and count in pandas?

size includes NaN values, count does not: In [46]: df = pd.DataFrame({‘a’:[0,0,1,2,2,2], ‘b’:[1,2,3,4,np.NaN,4], ‘c’:np.random.randn(6)}) df Out[46]: a b c 0 0 1 1.067627 1 0 2 0.554691 2 1 3 0.458084 3 2 4 0.426635 4 2 NaN -2.238091 5 2 4 1.256943 In [48]: print(df.groupby([‘a’])[‘b’].count()) print(df.groupby([‘a’])[‘b’].size()) a 0 2 1 1 2 2 Name: … Read more