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

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -