Formating a date with pattern using oracle

By: Martin Phee - mphee
Formating a date with pattern using oracle
2002-11-04 06:47
I have two Oracle date fields. Open_date, close_date. If I use a pattern of "MM/dd/yyyy" it works fine, but when I add HH:mm:ss I'm not getting the the time.

I worked around by doing a to_char on the field and putting it into the format I want.

I tried to do not pattern and all I got was '2002-11-02'.

pattern="MM/dd/yyyy HH:mm:ss" isn't working.


By: J rgen Lundberg - jorgen99
RE: Formating a date with pattern using oracl
2002-11-04 07:05
I'm not sure if I'm correct on this one, but I dont think that java.sql.Date has a time component.
Check out the JavaDocs:
http://java.sun.com/j2se/1.4.1/docs/api/java/sql/Date.html

/ J rgen



By: J rgen Lundberg - jorgen99
RE: Formating a date with pattern using oracl
2002-11-04 07:04
I'm not sure if I'm correct on this one, but I dont think that java.sql.Date has a time component.
Check out the JavaDocs:
http://java.sun.com/j2se/1.4.1/docs/api/java/sql/Date.html

/ J rgen



By: Martin Phee - mphee
RE: Formating a date with pattern using oracl
2002-11-04 07:06
I"m using java.lang.Date. That is what jasper supports.


By: J rgen Lundberg - jorgen99
RE: Formating a date with pattern using oracl
2002-11-04 07:13
I havn't checked, but if Jasper converts the sql.Date to a util.Date the time should be lost since sql.Date's time is 00:00:00.

Again, I'm making a qualified guess here... :)

/ J rgen



By: Martin Phee - mphee
RE: Formating a date with pattern using oracl
2002-11-04 07:30
How am I supposed to get the time then?


By: J rgen Lundberg - jorgen99
RE: Formating a date with pattern using oracl
2002-11-04 08:05
Do you have the date as a java.sql.Date or a java.sql.Timestamp? If you have a Timestamp then you should be able to get the time as well as the date. Both sql.Date and sql.Timestamp extends util.Date but only Timestamp has both date and time.



By: Martin Phee - mphee
RE: Formating a date with pattern using oracl
2002-11-04 08:14
Thank you. It worked. Replaced the filed and textexpression with Timestamp.
2001 JI Open Discussion's picture
Joined: Aug 10 2006 - 3:26am
Last seen: 17 years 1 month ago

0 Answers:

No answers yet
Feedback