0
data.date = new Date(jObjectTip.getLong("createdAt") * 1000);

このコマンドは、FourSquareからデータを取得するために使用されます。

4

2 に答える 2

1

うーん...「createAt」* 1000 が何を意味するのかわかりません。現在日時の1000倍?

Objective C では、以下を使用できます。

  • (id)initWithTimeIntervalSinceNow:(NSTimeInterval)seconds

https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSDate_Class/Reference/Reference.html

オフセット付きの日時オブジェクトを作成するには:

// creates a date time that is 1000 seconds away from the current time
NSDate *date = [[NSDate alloc] initWithTimeIntervalSinceNow:1000];
于 2012-10-25T08:50:01.460 に答える
1

createdAtこれが UNIX タイムスタンプであると仮定すると、コードは次のようになります。

NSTimeInterval createdAt = ...;
NSDate *resultDate = [NSDate dateWithTimeIntervalSince1970:createdAt];

NSTimeIntervalは の typedef でdoubleあり、Java とは異なり時間を秒単位で格納するため、値に 1000 を掛ける必要がないことに注意してください。

于 2012-10-25T08:53:21.890 に答える