我的Cassandra用户定义函数:-
CREATE OR REPLACE FUNCTION text2dt ( input text )
RETURNS NULL ON NULL INPUT
RETURNS timestamp
LANGUAGE java
AS '
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd HH:MM:SSS.SSS");
try{
java.util.Date date = sdf.parse(input);
return date;
}catch(Exception e){
return null;
}
';
我的查询是:-
select saumya.text2dt('2019-01-16 13:10:44.000') from system.local;
输出:-
2019-10-16 07:30:00.000000+0000