开发者

Objective C timestamp is not equal to java timestamp

开发者 https://www.devze.com 2023-04-12 01:57 出处:网络
I am working on an application receiving data from a backend. The problem is, that the dates are not working properly in my app. So I ended up comparing the timestamps generated by cocoa and the ones

I am working on an application receiving data from a backend. The problem is, that the dates are not working properly in my app. So I ended up comparing the timestamps generated by cocoa and the ones generated by my java backend.

Is there any reason that the java one is much longer than the objective c one?

Just compared:

java

开发者_运维问答

1318226845471

cocoa

1318226841

I am generating the cocoa timestamp with:

[[NSDate date] timeIntervalSince1970]

Any suggestions? I would appreciate any help!

Thanks in advance, Alex


Java returns milliseconds since Jan 1, 1970. Objective C is seconds since Jan 1, 1970

just use in java to get the result in seconds return (int) (System.currentTimeMillis() / 1000L);

0

精彩评论

暂无评论...
验证码 换一张
取 消