wood burning stoves
The moose likes JSF and the fly likes date conversion Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "date conversion" Watch "date conversion" New topic

date conversion

Jolie Lee
Ranch Hand

Joined: May 08, 2005
Posts: 87
hi, got problem with date conversion.

for my input field, i have dd-mm-yyyy, when i stored into ms-sql, it becomes, mm-dd-yyyy, when i retrieved, it becomes yyyy-mm-dd. how can i convert into the format of dd-mm-yyyy?

i'm using the getter methods to get all the data in the db, therefore i can't really format it before i display it in my jsp pages.

i tried the jsf convertdatetime as well but it didn't seems to work.

any advise pls?

Jys<br /><a href="http://jy-s.com" target="_blank" rel="nofollow">http://jy-s.com</a><br /> <br />Trying my very best to learn java, please forgive me if i'm asking some really stupid questions.
Arul Jose
Ranch Hand

Joined: Jan 14, 2005
Posts: 131
we are storing the time in milliseconds. so you can take it out and display it in any format.

Jolie Lee
Ranch Hand

Joined: May 08, 2005
Posts: 87
the data type i'm using for the date is datetime. i can't really change it because all the date are stored in this format.

when i create a getter method to convert the date into the format i want, it keeps giving me error:

javax.servlet.ServletException: An error occurred while evaluating custom action attribute "value" with value "${result.getPurchaseDateStr}": Unable to find a value for "getPurchaseDateStr" in object of class "$Proxy247" using operator "." (null)
Jolie Lee
Ranch Hand

Joined: May 08, 2005
Posts: 87
i guess i can't create my own get method to do the conversion...

how can i localize my date format, for eg, whenever i select a date from db, i will automatically format it into dd-mm-yyyy?
Varun Khanna
Ranch Hand

Joined: May 30, 2002
Posts: 1400
JSF provides date converter (Using DateFormat class) and it should work else you can use SimpleDateFormat class to do so while retriving your date from database.

- Varun
I agree. Here's the link: http://aspose.com/file-tools
subject: date conversion
It's not a secret anymore!