[英]Convert java Date to dbf FoxPro datetime format
Im trying to create DBF file in FoxPro spec, but idk how to insert date. 我试图在FoxPro规范中创建DBF文件,但是idk如何插入日期。 I dont know how to convert java Date to this:
我不知道如何将Java Date转换为此:
FoxPro's field is 2 32bit integers: one stores the date, the other stores the time, stored in reverse byte order.
FoxPro的字段是2个32位整数:一个存储日期,另一个存储时间,以反字节顺序存储。 The date integer stores the number of days from 1/1/4712BC.
日期整数存储从1/1 / 4712BC开始的天数。 The time integer stores the number of milliseconds from 00:00:00.
时间整数存储从00:00:00开始的毫秒数。
Its easy to get days and milliseconds with JodaTime: 使用JodaTime可以很容易地获得时间和毫秒:
DateTime start = new DateTime(-4713, 1, 1, 0, 0, 0, 0);
DateTime end = new DateTime(2014, 1, 1, 0, 0, 0, 0);
Days days = Days.daysBetween(start, end);
long millis = end.getMillisOfDay();
but how to convert this info to needed format? 但是如何将此信息转换为所需的格式? For input a date I just use:
为了输入日期,我只使用:
SimpleDateFormat simpledateformat = new SimpleDateFormat("yyyyMMdd");
simpledateformat.format(date);
and its work fine, but when I try use datetime with "yyyyMMddHHmmss"
I see very bad result, like 17.08.33409 12:34:20 (only month is correct). 并且它的工作正常,但是当我尝试将datetime与
"yyyyMMddHHmmss"
一起使用时,我会看到非常糟糕的结果,例如17.08.33409 12:34:20(仅月份正确)。
VFP has both Date and DateTime field types. VFP具有日期和日期时间字段类型。
The VFP syntax for inserting a date is: 用于插入日期的VFP语法为:
Insert into mytable (mydatefield) values ({^YYYY-MM-DD})
or 要么
Insert into mytable (mydatefield) values (Date(YYYY,MM,DD))
And for a datetime (assuming the field in VFP is a datetime) 对于日期时间(假设VFP中的字段为日期时间)
Insert into mytable (mydatefield) values ({^YYYY-MM-DD HH:MM:SS})
or 要么
Insert into mytable (mydatefield) values (DateTime(YYYY,MM,DD,HH,MM,SS))
So assuming you can extract a text representation of the year, month and day from your Java date you can build up your VFP query from that. 因此,假设您可以从Java日期中提取年,月和日的文本表示形式,则可以从中建立VFP查询。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.