【发布时间】:2014-08-23 01:04:57
【问题描述】:
如何在 TDateTime 中转换 TValue?
我看到有 AsInteger、AsDouble 等方法,但没有 TDateTime。
var
c : TRttiContext;
t : TRttiType;
f : TRttiField;
fieldValue : TValue;
fieldDateValue : TDateTime;
begin
c := TRttiContext.Create;
t := c.GetType(Self.ClassType);
for f in t.GetFields do begin
fieldValue := field.GetValue(Self);
//convert the TValue in TDateTime
end;
end;
【问题讨论】:
-
fieldValue.AsType<TDateTime> -
请停止在问题的文本和标题中添加“In Delphi”。
delphi标签让每个人都知道您的问题是关于 Delphi 的;没有必要到处重复添加它。此处的标签效果很好,既可以将您的问题展示在可以回答的人面前,也可以对其进行正确分类以进行搜索;它不需要重复的帮助。 :-) 谢谢。
标签: delphi reflection tdatetime tvalue