“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 .
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It depends what you mean by “looks like”. You can get a string representation of a
java.util.Dateusing aDateFormat(e.g.SimpleDateFormat). You’d want to set the time zone yourself, though.I believe that the internal structure of
NSDateis basically equivalent tojava.util.Date, based on the documentation: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.