java 如何在 HSQLDB 中创建特定日期?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13141328/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I create a specific date in HSQLDB?
提问by markthegrea
I need to create a HIGH date in HSQLDB and the solution is eluding me. I need something like
我需要在 HSQLDB 中创建一个 HIGH 日期,但我无法解决该解决方案。我需要类似的东西
Date(9999-12-31 0:0:0)
but I cannot find a function or whatever to do it. I am loding the date via Spring on startup and i need something like:
但我找不到一个函数或任何东西来做它。我在启动时通过 Spring 输入日期,我需要类似的东西:
insert intoMOD (
ITM_INST_ELECTR_MOD_STRT_TS,
ITM_INST_ID,
ELECTR_MOD_ID,
ITM_INST_ELECTR_MOD_END_TS
) VALUES (
CURRENT_DATE,
0,
0,
Date(9999-12-31 0:0:0)
)
What is the way to create a specific data using SQL in Hypersonic?
在 Hypersonic 中使用 SQL 创建特定数据的方法是什么?
回答by Jon Skeet
Given the user guide, I'd expect the following to work:
鉴于用户指南,我希望以下内容起作用:
DATE '9999-12-31'
or, if you need more than day precision:
或者,如果您需要超过一天的精度:
TIMESTAMP '9999-12-31 00:00:00'
回答by Thiago Santana
I was struggling with this problem and I think that I can contribute to help some other people.
我一直在努力解决这个问题,我认为我可以为帮助其他人做出贡献。
Here is the insert that you need to put on your script while loading hsqldb:
这是在加载 hsqldb 时需要在脚本中插入的内容:
insert intoMOD (
ITM_INST_ELECTR_MOD_STRT_TS,
ITM_INST_ID,
ELECTR_MOD_ID,
ITM_INST_ELECTR_MOD_END_TS
) VALUES (
CURRENT_DATE,
0,
0,
'9999-12-31'
)
HSQLDB converts the string automatically.
HSQLDB 会自动转换字符串。
I tested with latest version (2.3.3).
我用最新版本(2.3.3)进行了测试。