[英]How to read a TimeStamp datetime2(2) from a Sql database into Groovy
I am trying to read a TimeStamp datetime2(2) from a SQL server database which is in the format ' 2017-05-05 07:00:15.04 '. 我正在尝试从SQL Server数据库中读取TimeStamp datetime2(2),其格式为' 2017-05-05 07:00:15.04 '。 I get a formatting error in my groovy while executing. 我在执行时遇到了格式错误。
i Have used as follows: 我已经使用如下:
private DateTime Time_TimeStamp;
....
// getter and setters///
public DateTime getTime_TimeStamp() {
return Time_TimeStamp;
}
public void setTime_TimeStamp(DateTime time_TimeStamp) {
Time_TimeStamp = time_TimeStamp;
The error i receive is : FL_DPG_TimeAD.setTime_TimeStamp() is applicable for argument types: (java.sql.Timestamp) values: [2017-05-05 07:00:15.04] Possible solutions: setTime_TimeStamp(long), getTime_TimeStamp() 我收到的错误是:FL_DPG_TimeAD.setTime_TimeStamp()适用于参数类型:(java.sql.Timestamp)值:[2017-05-05 07:00:15.04]可能的解决方案:setTime_TimeStamp(long),getTime_TimeStamp()
How can i use exact datetime2(2) which is in format in groovy ? 我如何使用groovy格式的确切datetime2(2)?
the error 错误
FL_DPG_TimeAD.setTime_TimeStamp()
is applicable for argument types:(java.sql.Timestamp)
values:[2017-05-05 07:00:15.04]
FL_DPG_TimeAD.setTime_TimeStamp()
适用于参数类型:(java.sql.Timestamp)
值:[2017-05-05 07:00:15.04]
Possible solutions:
setTime_TimeStamp(long)
,getTime_TimeStamp()
可能的解决方案:setTime_TimeStamp(long)
,getTime_TimeStamp()
means that the method setTime_TimeStamp
in your object FL_DPG_TimeAD
accepts long
but you try to pass into this method java.sql.Timestamp
意味着该方法setTime_TimeStamp
在你的对象FL_DPG_TimeAD
接受long
,但你尝试通过这个方法java.sql.Timestamp
you just have to find a way to convert Timestamp
to long
您只需要找到一种将Timestamp
转换为long
check the documentation for java.sql.Timestamp
查看有关java.sql.Timestamp
的文档
there is a method getTime()
that returns timestamp as a long value 有一个方法getTime()
返回时间戳作为长值
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.