oracle 如何使用java从oracle数据库中以毫秒获取日期/时间?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11878030/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 01:02:02  来源:igfitidea点击:

How to get date/time with millisecond from oracle database using java?

javaoracletimestamp

提问by Babu R

I have the following TIMESTAMP value in oracle database.

我在 oracle 数据库中有以下 TIMESTAMP 值。

26-JUL-12 11.01.40.000000000 AM

When i getting this value from table , it displays without millisecond value like,

当我从表中获取此值时,它显示没有毫秒值,例如,

26-JUL-12 11.01.40 AM

But, i want to get this value like this format,

但是,我想像这种格式一样获得这个值,

26-JUL-12 11.01.40.000 AM

Is there any possible to get timestamp value in this format?

有没有可能以这种格式获取时间戳值?

Please help me.

请帮我。

Thanks in advance..

提前致谢..

回答by Raj

select to_char(systimestamp,'dd-mon-rrrr hh:mi:ss:ff3am') from dual;

回答by chinna_82

This article states:

这篇文章指出:

An Oracle DATE stores the date and time to the second. An Oracle TIMESTAMP stores the date and time to up to 9 digits of subsecond precision, depending on the available hardware.

Both are implemented by storing the various components of the date and the time in a packed binary format. From the Oracle Concepts Guide section on dates

Oracle uses its own internal format to store dates. Date data is stored in fixed-length fields of seven bytes each, corresponding to century, year, month, day, hour, minute, and second.

You can use the DUMP() function to see the internal representation of any particular date (or any other value for that matter), but that's probably more than you need (or want) to know.

Oracle DATE 将日期和时间存储到秒。Oracle TIMESTAMP 将日期和时间存储为最多 9 位亚秒级精度,具体取决于可用硬件。

两者都是通过以打包的二进制格式存储日期和时间的各种组件来实现的。来自 Oracle 概念指南关于日期的部分

Oracle 使用自己的内部格式来存储日期。日期数据存储在每个七字节的固定长度字段中,对应于世纪、年、月、日、小时、分钟和秒。

您可以使用 DUMP() 函数来查看任何特定日期(或任何其他与此相关的值)的内部表示,但这可能比您需要(或想要)知道的要多。