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). :)

java util date method

nsdate method


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

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -