title: Date4j compare 2 times
body: <p>So, it's my understanding that Date4J (<a href="http://www.date4j.net/javadoc/hirondelle/date4j/DateTime.html" rel="nofollow">http://www.date4j.net/javadoc/hirondelle/date4j/DateTime.html</a>) is a little bit easier to use than JodaTime so I've been using it in one of my projects.  It's working out well, but I'm trying to create a last seen function for the last time an event took place.  I have 2 objects, lastOnline and now.  Their values are as follows:</p>
  
  <pre><code>LastOnline year 2015---Now.year--2015
  LastOnline Month 1---Now.Month--1
  LastOnline Day 18---Now.Day--18
  LastOnline Hour 14---Now.Hour--14
  LastOnline Minute 13---Now.Minute--33
  LastOnline Second 24---Now.Second--15
  LastOnline NanoSecond 1421590404000---Now.Nanosecond--1421591595316
  </code></pre>
  
  <p>I got that with the following commands: </p>
  
  <pre><code>    System.out.println("LastOnline year " + lastOnline.getYear() + "---Now.year--" + now.getYear());
      System.out.println("LastOnline Month " + lastOnline.getMonth() + "---Now.Month--" + now.getMonth());
      System.out.println("LastOnline Day " + lastOnline.getDay() + "---Now.Day--" + now.getDay());
      System.out.println("LastOnline Hour " + lastOnline.getHour() + "---Now.Hour--" + now.getHour());
      System.out.println("LastOnline Minute " + lastOnline.getMinute() + "---Now.Minute--" + now.getMinute());
      System.out.println("LastOnline Second " + lastOnline.getSecond() + "---Now.Second--" + now.getSecond());
      System.out.println("LastOnline NanoSecond " + lastOnline.getMilliseconds(TimeZone.getTimeZone("UTC")) + "---Now.Nanosecond--" + now.getMilliseconds(TimeZone.getTimeZone("UTC")));
  </code></pre>
  
  <p>With that said, I took a look at the documentation for the .minus function and I can't seem to get it to work, it's throwing a ton of NullPointerExceptions and I can't seem to figure out why.  Here is my minus function:</p>
  
  <pre><code>DateTime difference;
  difference = now.minus(lastOnline.getYear(), lastOnline.getMonth(), lastOnline.getDay(), lastOnline.getHour(), 
  lastOnline.getMinute(), lastOnline.getSecond(), lastOnline.getNanoseconds(), DateTime.DayOverflow.FirstDay);
  </code></pre>
  
  <p>And lastly here's a stack trace-- </p>
  
  <pre><code>java.lang.NullPointerException
  at hirondelle.date4j.DateTime.minus(Unknown Source)
  at globalFunctions.compareTime(globalFunctions.java:177)
  at globalFunctions.logScrape(globalFunctions.java:158)
  at Commands.bangCommands(Commands.java:32)
  at Commands.handleCommands(Commands.java:9)
  at listener.main(listener.java:53)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:606)
  at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
  </code></pre>