oracle 字符串到java中的oracle日期
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3827848/
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
string to oracle date in java
提问by apoorvabade
I have a string in the format "dd.mm.yyyy hh:mm".. i need to convert it into oracle date format 'dd-mon-yy'..... How do i make it happen???
我有一个格式为“dd.mm.yyyy hh:mm”的字符串..我需要将它转换为oracle日期格式'dd-mon-yy'.....我该如何实现???
采纳答案by D0cNet
How is the string sent to oracle?? Use the to_date() function to convert the java string to oracle date. http://www.techonthenet.com/oracle/functions/to_date.php
字符串如何发送到oracle??使用 to_date() 函数将 java 字符串转换为 oracle 日期。 http://www.techonthenet.com/oracle/functions/to_date.php
回答by OMG Ponies
It's not clear where the string is, considering the java tag... Assuming a column value:
考虑到 java 标签,不清楚字符串在哪里......假设列值:
SELECT TO_CHAR(TO_DATE(t.column, 'DD.MM.YYYY HH24:MI'), 'DD-MON-YYYY')
FROM YOUR_TABLE t
回答by Sean
If you want to perform an sql query against your database via prepared statment you can use
如果您想通过准备好的语句对您的数据库执行 sql 查询,您可以使用
java.sql.Date
which stores the Date. Note that this object does not store time, just month, day and year. Also see
存储日期。请注意,此对象不存储时间,只存储月、日和年。另见
java.sql.Time
java.sql.Timestamp
If you are looking to format the date for display purpose, try
如果您希望格式化日期以用于显示目的,请尝试
java.text.DateFormat