I have a facelet page with one field for the date and another for the time. I am trying to use the f:convertDateTime to format the fields. This is where things begin to get confusing. It seems as if the f:convertDateTime only works with the Date object. Isn't the Date object marked for deprecation? I also seem to be having a problem with the time information field, which is a Date object. For some strange reason, the time information seems to get lost and I end up with a default time of 00:00:00. Any help would be greatly appreciated.
No, Date isn't deprecated, although the "brute-force" initializers for month, day and year have been since about Java 1.2 (in favor of Calendars).
Date is like floating-point in that it can really zap you. Officially, it has a granularity of milliseconds. But a number of things can affect that. One of the prime offenders is databases. Date objects are often stored to SQL date database objects that have a different granularity, resulting in loss of data. Some databases define a date object as a true date with a granularity in days. Some are precise to seconds, and I think one even has 1/10th-second granularity. It can be a major headache, especially if you're unwise enough to attempt to use a date or timestamp as a database index item. Then there's alternative "Date" classes like TimeStamp, as well as alternative database SQL types...
On top of that, the JSF convertDateTime has its own idiosyncrasies, so it's not a bad idea to keep the antacids nearby.
Customer surveys are for companies who didn't pay proper attention to begin with.
The convertDateTime is an excellent tag which I use widely in my project. Probably you might have encountered some problem in setting the date object.
1. If you are getting the date from the database whic is of type 'timestamp' or 'Date', then we need to convert the obtained date to java.util.Date.
TimeStamp time = <timestamp from database>
This snippet will work while using convertDateTime in the frontend.
Just a typecast would suffice
2. If you are mannually setting the date in the java code, make sure you set the time information also; else the time information will show as 00:00:00 in the page. I dont think there are any way in which the time information gets lost.
3. If you are getting date in the form of string[say from Mainframe, or an inputText], then you can use simpleDateFormatter to convert.