Reputation: 1893
"NSDate timestamp" looks like "2012-12-11 18:30:41 - 400". The java timestamp is just a long integer (for example:"276712445500").
So, What is a Java equivalent for nsdate?
Thanks in advance .
Upvotes: 0
Views: 1785
Reputation: 1500875
It depends what you mean by "looks like". You can get a string representation of a java.util.Date
using a DateFormat
(e.g. SimpleDateFormat
). You'd want to set the time zone yourself, though.
I believe that the internal structure of NSDate
is basically equivalent to java.util.Date
, based on the documentation:
The sole primitive method of NSDate, timeIntervalSinceReferenceDate, provides the basis for all the other methods in the NSDate interface. This method returns a time value relative to an absolute reference date—the first instant of 1 January 2001, GMT.
In other words, the value doesn't "know" its offset from UTC etc... it's just a point in time. (The epoch and scale may well be different to java.util.Date
, but that's an implementation difference more than a conceptual one.)
However, despite all of this I would strongly recommend that you use Joda Time for all date/time manipulation in Java. It's a much nicer API than java.util.Date
/Calendar
.
Upvotes: 1