开发者

string to oracle date in java

I have a strin开发者_StackOverflow社区g 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???


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


It's not clear where the string is, considering the java tag... Assuming a column value:

SELECT TO_CHAR(TO_DATE(t.column, 'DD.MM.YYYY HH24:MI'), 'DD-MON-YYYY')
  FROM YOUR_TABLE t   


You can use to_char() method of oracle. You can get more information about date conversion here.


If you want to perform an sql query against your database via prepared statment you can use

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜