Well, after spending about two days trying to figure out how to compare to date objects to get the days different between them I'm coming to the experts for help.
Here is my code.
String sLlpc = String.valueOf(ldt_last_passwd_changed);
int d = Integer.valueOf(sLlpc.substring(5,7)).intValue();
int m = Integer.valueOf(sLlpc.substring(8,10)).intValue() - 1;
int y = Integer.valueOf(sLlpc.substring(0,4)).intValue();
System.out.println(d);
System.out.println(m);
System.out.println(y);
Calendar c1 = new GregorianCalendar(y, m, d);
System.out.println(c1.getTime().toString());
Calendar cNow = Calendar.getInstance();
System.out.println(cNow.getTime().toString());
long diffMillis = c1.getTimeInMillis()-cNow.getTimeInMillis();
System.out.println(diffMillis);
ll_password_age = diffMillis/(24*60*60*1000);
System.out.println("Password age: "+ll_password_age);
Here is the ouput to stdout.
2005-07-28 12:30:29,875 INFO [STDOUT] 7
2005-07-28 12:30:29,890 INFO [STDOUT] 27
2005-07-28 12:30:29,890 INFO [STDOUT] 2005
2005-07-28 12:30:29,890 INFO [STDOUT] Sat Apr 07 00:00:00 CDT 2007
2005-07-28 12:30:29,890 INFO [STDOUT] Thu Jul 28 12:30:29 CDT 2005
2005-07-28 12:30:29,890 INFO [STDOUT] 53350170110
2005-07-28 12:30:29,890 INFO [STDOUT] Password age: 617
As you can see I'm pushing in a date of 07/27/2005(not quite that format, but that shouldn't matter), and comparing it with today's date to get the number of days between the two.
It seems like what I have should work, but when I get the gregorian calendar instance is seems to interpret the int values incorrectly.
Does anyone know how I can fix this?
Thanks