memesearch
Java Date Subtraction Confusion

Java Date Subtraction Confusion

Download Find similar pictures
Text on the meme
Subtracting the Date in Java This question may seem similar with others, but actually it's not the same case. This code will return the difference in days between two dates, but it doesn't return a negative number. Date currentdate = calendar.getCurrentDate(); Date referencedate = calendar.getDate(); long math = Math.abs(currentdate.getTime() - referencedate.getTime()); long result = math / (24 * 60 * 60 * 1000); System.out.println(result); I want to get a negative number in order to know if the current date is being subtracted from a past date or a future date. How to make this code return a negative number as well? OBS: I can't use Date.after() or any other method from java.util.Date because the framework I'm working with doesn't allow me to use those methods, because it has its own Date class. java validation date datetime datepicker share edit asked 14 mins ago Rafa 116 6 have you tried giving a thought to use Joda which is a datetime library exclusively Satya 12 mins ago I wonder what Math.abs() does... — shmosel 12 mins ago add a comment
What it means

A Stack Overflow screenshot shows a Java programmer asking how to make date subtraction return a negative number, while the highlighted code explicitly uses Math.abs(), which removes the negative sign. The joke is that the answer is plainly visible in the programmer’s own code, making this a reaction to an obvious programming mistake or failure to read one’s implementation.

Objects
Tags
Sources
Template
Stack Overflow question screenshot
Type
image
Size
800×550 · 79.7 KiB
Mood
sarcastic, absurd
Language
en
Added