Posts

Showing posts with the label java

Java Date Comparisons

I've just started to use Java, having never coded with it before, and today ran into a bit of trouble with date comparisons.  The obvious option that I wanted to use had been deprecated so I needed to find an alternate. Whilst Google and StackOverflow are normally my very best friends when it comes to this sort of issue, today they were only a little helpful, pointing me in roughly the right direction but not actually hitting the target. What I needed to do was add 6 years to a variable date and then compare that to today's date.  Sounds easy enough, and in Java version 6 it was, but now things have changed.   I found a useful class called Calendar, however, all the online blogs, tutorials and user comments only showed me how to add years to today's date, which is easy as pie.  What none of them told me was how to add 6 years to another date.   It's probably really obvious for most folks out there, but given the number of questions I found by people askin...