java - Convert JavaUtilDate to NSDate and vice versa? -
i use j2objc translate java util date objective-c javautildate class. imported #import "java/util/date.h"
to store translated java date variable.
var mydate: javautildate
how convert javautildate
nsdate
?
depending on where/how java date, best bet milliseconds , instantiate nsdate it.
so call gettime() method on java date milliseconds since epoch, create nsdate datewithtimeintervalsince1970: method. nsdate method takes seconds (as floating point), divide 1000.0 keep precision (thanks martin r pointing out in comments). :)
there seems confusion on being asked. general possible, time objects typically have method milliseconds since epoch , constructor (or setter) pass in seconds since epoch. have seconds 1 object , instantiate other object seconds.
Comments
Post a Comment