0

我创建了一个具有类型列的列族

{column_name: dob, validation_class: DateType}

现在我想通过 CLI 在列中插入一个日期。

当我尝试插入一个值时,它会出现以下错误:

“无法将 '1988-1-1'T'01:45:12:112' 强制转换为格式化日期(长)”

如果有人能指出我哪里出错了,我将不胜感激。

4

2 回答 2

1

自您日期的 Unix 纪元时间戳(1988 年 1 月 1 日 01:45:12.112 GMT+0000 (GMT)。我假设此处为 GMT,未指定时区)以来的毫秒数为 567999912112。

假设您的 CF 架构定义如下所示:

create column family test with column_type='Standard' 
   and key_validation_class = 'UTF8Type' 
   and comparator='UTF8Type'  
   and default_validation_class = 'UTF8Type'
   and column_metadata = [
      {column_name : 'dob', validation_class : DateType}
      ];

以下 Cassandra CLI 命令正确插入您的日期:

set test['userID']['dob']=567999912112;

要测试它,请尝试:

get test['userID'];
于 2012-09-12T11:15:05.267 回答
0

您必须将日期转换为 unix 纪元时间戳。

于 2012-06-28T10:09:03.327 回答