Hello all.
I'm more a JSP scripter than a fully fledged Java developer. This has lead to a rather blinkered view of Java - and, as hilighted in this case, I am struggling to get to grips with some rather simplistic code requirements. My current role does not give me the chance to develop my Java any further at work.
I'm successfully creating a new calendar and getting out the milliseconds "since the epoch"... converting this into a String and then assigning this to a cookie (so I have a string representation of a long). On another page I want to compare the difference between the current milliseconds and the milliseconds stored in my cookie. I can get the value from the cookie and store it in a String... no problems. After that... I'm stuck!
Initially I had attempted to just convert both to a Long and then subtract one from the other... but I found that I was unable to do a simple subtraction (Delta = Long - Long) - I got all kinds of errors. So I moved on to thinking I would create 2 date objects and then compare them (since I had the initial milliseconds as a string, and I could easily coerce the current milliseconds into another string). I then ran into so many problems trying to construct a new date using setTimeInMillis(), that after over 3 hours I have given up trying to solve this by myself.
Rather than waste your time trying to dictate how I want to solve the problem... could someone please advise the most simplistic approach, and put up some code that will get me started? I am running this using Tomcat 4.1.12 and using the J2SDK 1.4.3_03 should it make any difference.
Much appreciated,
Jeff
I'm more a JSP scripter than a fully fledged Java developer. This has lead to a rather blinkered view of Java - and, as hilighted in this case, I am struggling to get to grips with some rather simplistic code requirements. My current role does not give me the chance to develop my Java any further at work.
I'm successfully creating a new calendar and getting out the milliseconds "since the epoch"... converting this into a String and then assigning this to a cookie (so I have a string representation of a long). On another page I want to compare the difference between the current milliseconds and the milliseconds stored in my cookie. I can get the value from the cookie and store it in a String... no problems. After that... I'm stuck!
Initially I had attempted to just convert both to a Long and then subtract one from the other... but I found that I was unable to do a simple subtraction (Delta = Long - Long) - I got all kinds of errors. So I moved on to thinking I would create 2 date objects and then compare them (since I had the initial milliseconds as a string, and I could easily coerce the current milliseconds into another string). I then ran into so many problems trying to construct a new date using setTimeInMillis(), that after over 3 hours I have given up trying to solve this by myself.
Rather than waste your time trying to dictate how I want to solve the problem... could someone please advise the most simplistic approach, and put up some code that will get me started? I am running this using Tomcat 4.1.12 and using the J2SDK 1.4.3_03 should it make any difference.
Much appreciated,
Jeff