标签:
procedure TForm1.FormCreate(Sender: TObject); var n: TDateTime; i64: Int64; s: Integer; begin Memo1.Clear; Memo1.ReadOnly := True; n := StrToDateTime(‘2014-05-02 10:37:35‘); Memo1.Lines.Add( IntToStr( DateTimeToUnix(N) - 28800 )) ;//1398998255 Memo1.Lines.Add( IntToStr( DelphiToJavaDateTime(N ))); //1398998255000 Memo1.Lines.Add( DateTimeToStr( JavaToDelphiDateTime(DelphiToJavaDateTime(N )))); //2014-05-02 10:37:35 with TRegistry.Create(KEY_WOW64_64KEY or KEY_ALL_ACCESS) do try RootKey := HKEY_LOCAL_MACHINE; if OpenKey(‘SOFTWARE\Microsoft\Windows NT\CurrentVersion‘, False) then begin Memo1.Lines.Add(IntToStr(ReadInteger(‘InstallDate‘)));//1398998255 Memo1.Lines.Add(DateTimeToStr(UnixToDateTime(ReadInteger(‘InstallDate‘) + 28800))); //2014-05-02 10:37:35 i64 := ReadInteger(‘InstallDate‘); //这里 必须先这样转为64位,不能直接 * 1000,直接的话,按integer类型计算,结果超过MaxInt了。 i64 := i64 * 1000; Memo1.Lines.Add(DateTimeToStr(JavaToDelphiDateTime(i64))); //2014-05-02 10:37:35 end; finally Free end; end;
JavaToDelphiDateTime和DelphiToJavaDateTime有2个特点:
superobject中 JavaToDelphiDateTime的使用
标签:
原文地址:http://www.cnblogs.com/CodeGear/p/4760630.html