Dates and forms with JDBC - there must be a better way...

Hi,
I have a backing bean (CustomerBean) extended from class Customer that talks to a DOA for access to a JDBC pooled resource.
I am having trouble getting an elegant solution for getting dates in and out of the DB using JSF forms.
My Customer class defines the date as java.sql.Date - passing that through to the form gives errors during validation. The work around I managed to get working is for the CustomerBean to have a method that converts a java.util.Date to a java.sql.Date.
public void setStartDate(java.util.Date startDate) {
if (startDate == null)
super.setStart(null);
else
super.setStart(new java.sql.Date(startDate.getYear(),startDate.getMonth(),startDate.getDate()));
and
public java.util.Date getStartDate() {
return super.getStart();
using:
<h:outputLabel value="Start"/>
<h:inputText id="startDate" value="#{customerBean.startDate}" required="false">
<f:convertDateTime pattern="dd/MM/yyyy"/>
</h:inputText>
<h:message for="startDate" styleClass="message"/>
the super property 'start' is a java.sql.Date. The line that bothers me is:
super.setStart(new java.sql.Date(startDate.getYear(),startDate.getMonth(),startDate.getDate()));
it uses deprecated constructor. (java.sql.Date(int year, int month, int day);
Where should I be looking for a more elegant solution? (GregorianCalendar? Anything else?)
Thanks in advance,
- David

Thanks...
I did it this way:
Customer.java has...
private java.sql.Date start;
and getters and setters...
CustomerBean.java extends Customer, has no field but the getters and setters...
public java.util.Date getStartDate() {
return super.getStart();
public void setStartDate(java.util.Date startDate) {
if (startDate == null)
super.setStart(null);
else
super.setStart(new java.sql.Date(startDate.getTime()));
seems to work and my customer has it's dates as sql dates (that way I only convert dates when I actually need them updateable on screen rather than each read of a customer record from the DB.)
To display the date I use
<h:outputText value="#{customerBean.startDate}">
<f:convertDateTime dateStyle="full"/>
</h:outputText>
To edit it, I use
<h:inputText id="startDate" value="#{customerBean.startDate}" required="false">
<f:convertDateTime dateStyle="short"/>
</h:inputText>
Is this a valid or recommended way?
- David

Similar Messages

  • Adobe support is hopeless, there must be a better way, if not it might be better to get a different movie program. is anyone having the same problem?

    adobe support is hopeless, there must be a better way, if not it might be better to get a different movie program. is anyone having the same problem? 

    This is like buying a GM car and being told to talk to otherGM customers on how to fix your car yourself.  It it the blind leading the blind.   I have wasted many days and weeks because I cannot find solutions.  I have rarely gotten a solution from any similar forum, and more often been told by other members that I should buy what they have or that I should not want to make this or that type a disc, etc., and rarely a suggestion that is useful.

  • RESTORE to free up fragmented iPod disc space? There must be a better way!

    I've owned iPods since day one and yet I continue to (barely) tolerate an annoying circumstance, as follows: manually deleting songs and videos (mind you, I'm not referring to playlists) will free up some space on [put your iPod iteration here] but NEVER results in freeing up space equal to the size of the songs or videos deleted. As a result, the remaining "fragmented" space builds up over time and creates a serious loss of available "free" space — unless one performs a Restore and starts loading from scratch. Happily, Restore will double — or triple! — the amount of available (re: writable) space on iPods — but serious cost in personal time and trouble
    For those of us with high capacity iPods — I can hear you yelling, "Me! Me!" — why, alas, does Restore continue to be the only way for us to manually rebuild the iPod library (thereby resulting in much more writable (rer: available) disk space)?
    There must be an easier way? Countless searches of Apple Discussions produces nothing more than endless refrains of "Restore, Restore, Restore!"
    Me, I'm tired of manually restoring 25 GBs of songs/videos in order to free up that extra 50 percent of writable space.
    How about you?
    5G 30GB ipod   Mac OS X (10.4.4)  

    Welcome to Apple Discussions.
    Me, I'm tired of manually restoring 25 GBs of songs/videos in order to free up that extra 50 percent of writable space.
    Buy a larger-capacity iPod, then.
    If you really feel like Apple will hear you with your complaints, then do it here. Unless you have something that I can help you with, then please ask.
    rjl

  • Callouts and anchored objects - there must be a better way to do this

    I've spent a lot of time in the last six months rebuilding PDF files in InDesign. It's part of my ordinary responsibilities, but I'm doing a lot more of it for some reason. Because I'm sending the text of these rebuild documents out for translation, I like to keep all of the text in a single story. It really helps to have the text in "logical order," I think; when I'm prepping a trifold brochure, I try pretty hard to make sure that the order in which the readers will read the text is duplicated in the flow of the story throughout the ID document.
    So, I'm rebuilding a manual that has a 3-column format on lettersize paper, and it's full of callouts. Chock full of 'em. They're not pull quotes, either; each of these things has unique text. Keeping in mind that I'd like the text in these callouts to remain in the same position in the text once I've linked all the stories and exported an RTF for translation, what's the best way to handle them? What I've been doing is inserting an emptly stroked frame as an anchored object, sized and positioned to sit above the text that is supposed to be called out. When my translations come back, they're always longer than the source document, so as I crawl through the text, I resize the anchored frames to match the size and position of the newly expanded translated text, and then nudge them into place with the keyboard.
    There Has To Be a Better Way.
    There is a better way, right? I'm not actually too sure. If I want to actually fill those anchored frames with text, I can't thread them into the story. I suppose that I could just thread the callout frames and assign two RTFs for translation instead of one, but then the "logical order" of my text is thrown out the window. So, I'm down to asking myself "what's more important? reduction of formatting time or maintenance of the flow of the story?" If there's something I'm missing that would let me dodge this decision, I'd love to hear about it. The only thing I can think of would work like this:
    1) Duplicate callout text in the story with a custom swatch "Invisible"
    2) Create "CalloutText" parastyle with "Invisible" swatch and apply it to callout text
    3) Insert anchor for anchored frame immediately before the CalloutText content
    4) Send it out for translation
    5) While I'm waiting for it to come back, write a script that would (dunno if this is possible):
       a) Step through the main story looking for any instance of CalloutText
       b) Copy one continguous instance of that style to the clipboard
       c) Look back in the story for the first anchor preceeding the instance of CalloutText
       d) Fill the anchored object with the text from the clipboard (this is where I'm really clueless)
       e) Apply a new parastyle to the text in the callout
       f) Continue stepping through the story looking for further instances of CalloutText
    If this really is the only decent solution, I'll just head over to the Scripting forum for some help with d). Can any of you make other suggestions?

    In-Tools.com wrote:
    The use of Side Heads saves weeks of manual labor.
    Yup, Harbs, that is exactly what I was describing. If I use the Side Heads plugin to set up a job, will my clients get a missing plug-in warning when they open up the INDD? Will roundtripping through INX strip the plugin but leave the text in the callout? (My clients don't care if the logical flow of the story is broken; it's just me.)
    I'm just curious; seems like a pretty obvious purchase to me. I'll probably try to script a solution anyways, after I buy the plugin; that way I get to learn about handling anchored objects in scripts AND deliver the job on time!

  • Bloody sick of Itunes Restrictive Schemes, there must be a better way!

    Don't get me wrong, I love my macs and itunes and ipods and iphones and all the rest but I am sick of being told how to manage media by Apple. I've read this:
    http://support.apple.com/kb/HT1495
    but I want this:
    1) a single media library on a home server/external drive
    2) access to that media from any ipod that I own (3) from any machine that I happen to be near at the moment.
    3) without having separate iTunes accounts, all should be shared with the same ratings and playlists and whatnot.
    Is there anyway yet to do this? thx for helping us break out of this NWO media management!

    1) a single media library on a home server/external drive
    OK. You can do that now - lots of people do. There are several ways to accomplish that depending on how you want things to work, and they've all been described here and on many other web site. What's preventing you from doing the same?
    2) access to that media from any ipod that I own (3) from any machine that I happen to be near at the moment.
    OK. Set your iPods for manual management and you can load them from any computer with iTunes.
    3) without having separate iTunes accounts, all should be shared with the same ratings and playlists and whatnot.
    OK. Keep the entire iTunes library, including the library files, on the external drive. Then using the Option-key launch of iTunes, point all your copies of iTunes to that library folder. Then every system will have the exact same edition of iTunes, including all the same playlists, ratings, and whatnot.
    Alternatively, one of the synchronization utilities such as TuneRanger might work for you, if you don't want each system to have the same playlists, etc. but want to transfer ratings, etc.
    Message was edited by: Dave Sawyer

  • Upgrading to Lion, There Must be a Better Way Than Migration Assistant!

    I finally got around to updating to Lion and it's turned out to be a little frustrating.
    First Attempt: simply updating over the top of my existing Snow Leopard installation. I had a variety of annoyances mostly surrounding the amazing amount of cruft laying around from years of installing,  then removing apps and just upgrading new versions of Mac OS on top of the existing ones.
    Second Attempt: Partition the drive, did a clean installation, used Migration Assistant and moved my old account to the new installation. This resulted in most of the cruft coming over, many of the annoyances remaining, and some settings and daemons mysteriously disappearing.
    Third Attempt: Deleted the second attempt, did another clean installation, created a new account with the same name as the old account, and then copied only the data I really wanted (Documents, iTunes Library, Mail Data, &tc...). This resulted in dozens of annoyances stemming from permission problems.
    So... how do I jettison all the artifacts from the past while only keeping the data I really want? How do developers deal with having more than one working installation on a Mac? Do they never move stuff between them?

    I pretty much agree with baltwo on this. The only way to weed out the 'cruft' is to reinstall each program manually, copy data from your Pictures, Documents, Music, and Movies folders. Then to be very careful about what you move from the old Library into the new one. Invariably this process leads to missing templates and other issues that take several days - and longer - to resolve. The end result? Your computer doesn't run noticeably faster and you gain perhaps a whopping couple GB or less of drive space.
    I speak from experience. I have performed this painful task twice (and was very thankful to have complete backups that I didn't erase because I didn't realize I was missing some templates for several months). My two work desktops and notebook go all the way back to Jaguar and they are no faster than my home computers of the same vintage.

  • Fios availabili​ty - There must be a better way

    I have truly worked hard to try to be a Fios customer!  6 phone calls for 4 hours and 3 weeks later I still can't give Verizon my money. For whatever reason my address is not listed in the "Fios available" directory and no one seems to be able to figure out why. Neighbors on both sides and across the street are all listed as available. I was solicited for Fios when they installed it on my street years ago. So here I am with money in hand, Fios in front of my house and I can't become a customer ... go figure! I feel that the main problem is that because I am not a current customer, there is no record of me calling or anything. Each time I have called I have had to go through the same speech, same information, different person. I have talked to everyone from sales, customer service, tech support and engineering. No solution!
    I am the best customer possible ... no advertising required, no sales team required. I will even place my order online, so no people are required but here I sit with my money in my hand!
    THIS SHOULD NOT BE THIS HARD!

    Please check your Private Message Inbox. It should look like this -->> 
    If a forum member gives an answer you like, give them the Kudos they deserve. If a member gives you the answer to your question, mark the answer that solved your issue as the accepted solution.

  • Hello! I want to set up an appointement with Genius Bar but when i choose the available date and try to confirm there is this message appears : We're sorry. There was an error processing your request. Click OK to try again. HELP ME PLEASE

    Hello! I want to set up an appointement with Genius Bar but when i choose the available date and try to confirm there is this message appears : We're sorry. There was an error processing your request. Click OK to try again. HELP ME PLEASE

    I have called the store with the same problem but the answer is this must be done on line. I was told to use a different browser but it has made no difference - I am still having the same problem

  • How to show Date and Time with TimeZone

    Dear All,
    I have to show Date and Time with TimeZone abbreviation,
    for example:
    1) 31 March 2011 2:30 in india standard time - it should show in screen 31 March 2011 2:30 IST.
    2) 31 March 2011 2:30 in Australia/New Zealand - Eastern time zone it should show in screen 31 March 2011 2:30 AEST.
    how can i show *Australia/New Zealand - Eastern time zone to AEST*,
    I tried with format DD MMM YYYY HH:MM zzz, and i looked time zone API too.
    Appreciate your help
    Thanks
    Daya

    Dayananda wrote:
    ok, than i have to use zzzz format, as z won't help in my case, so i have to use zzzz which display descriptive value like, Indian Standard Time i.e. ISTPer the javadocs there is a very specific reason why that is a problem especially if you intend to support many timezones in one application.
    "+For compatibility with JDK 1.1.x, some other three-letter time zone IDs (such as "PST", "CTT", "AST") are also supported. However, their use is deprecated because the same abbreviation is often used for multiple time zones (for example, "CST" could be U.S. "Central Standard Time" and "China Standard Time"), and the Java platform can then only recognize one of them+."
    Thus you have one single case where there can be many and moreover it can change (twice a year I believe.)
    There is a standard source for this information although when I tried it it appears to not work.
    If the app only needs to display one zone then provide a configuration value that allows a user to overload the display value.
    If the app needs to display many values then you MUST inform business users of the problem because there are duplicates and they, not you, need to decide specifically what happens in those cases.

  • Converting part of the string to a date and subtract with sysdate.

    HINT! In order solve this you must know how the pnr is assembled. Study this:
    650323-5510, we only need the first six characters. They inform us about when the person (car owner) was born. In this case it is 23 Mars 1965. You have to use several oracle built-in-functions to solve this. Hint! Begin by converting part of the string to a date and subtract with sysdate.
    select to_char(to_date(cast(pnr,'YYMMDDMM'))) from car_owner;
    please what am i doing wrong. i need the result to be something like this
    Hans, Rosenboll, 59,6 years.

    Hi.
    The main problem here is you have only last two digits of year. That could be the problem in a couple of years from now, when somebody born after 2k would get in to your database. For now if we ignore this problem the right solution would be :
    <code>
    SELECT months_between(trunc(SYSDATE),
    to_date('19' || substr('650323-5510',
    1,
    6),
    'YYYYMMDD')) / 12 years_old
    FROM dual
    </code>
    Suppose you are expecting the age of the car owner as a result above code will give you that. One again notice the '19' I appended.
    Best regards.

  • Each time master data full load removes previous data and load with new ?

    We load company code (0COMP_CODE) master data (full load).
    1st day, we check company code master data, the record count is 150, 2nd day, the record count is 90.  It sounds like the master data full load each time would clean the previous data and load with new data, am I right?  If what I guess is right, then what setup is controlling this?
    Thanks

    I dont think it does cleanup.
    MD records in the new load simply overwrite the records already present in the master data.
    I mean if same record comes again its overwritten.If new record it gets added.
    I wouldnt expect number of records to reduce drastically from 150 to 90.
    Maybe before MD activation records could be more(as there will be both M(modified) and A(active) records).
    cheers,
    Vishvesh

  • How can I bulk delete contacts from my iPhone 4S? I've imported contacts from gmail and hotmail, many of which I don't need. Deleting them individually will take ages, there must be a quicker way. Also, are my contacts taking up space on my iPhone or

    How can I bulk delete contacts from my iPhone 4S? I've imported them from gmail and hotmail and there are many more than I need. Deleting them one by one will take ages, there must be a quicker way! Also, do contacts take up space on the phone or are they stored remotely?
    Thanks.. J

    You should be syncing your contacts with an app on your computer or cloud service (iCloud, Gmail, Yahoo, etc), and not relying on a backup.  If you haven't been doing this, start now and then restore your old backup.  You will then be able to sync the new contacts back into the phone.  However, you will lose all messages, etc newer thant the backup.

  • Using JCheckBox, JButton and JTextArea with JDBC

    Hello shlumph and SoulTech2012.
    thanks for the reply. I�m wondering do any of you have links to web pages that include tutorials and source code on using JCheckBox, JButton and JTextArea with JDBC. would any of you who have experience with using JCheckBox, JButton, JTextArea and JDBC together be able to give me a few tips on how to select certain data from a table using JCheckBox, JButton and display the data in a JTextArea? examples of such data could be CD/DVD/Game data - i want users of my video library system to be able to view CD/DVD/Game information by name, age category, type and year. Users should be able to click on a check box (e.g. view by name, age category, type or year) and press a button. What would happen then is that data from the Product table would appear in the text area (which could be placed beneath the check box + button inside a frame and/or panel).
    Thank you very much for your help.

    Quit triple posting and cross posting your questions all over the forum. You already have a posting in this forum on this topic and another posting in the Swing forum and another posting in the Programming forum.

  • Hello If I am discovered and noted a gap in ios7 How can I deliver them to you and clarification knowing that there must be a video chat

    Hello
    If I am discovered and noted a gap in ios7
    How can I deliver them to you and clarification knowing that there must be a video chat

    talabtalab wrote:
    If I am discovered and noted a gap in ios7
    You mean "bug"? If so, only registered developers can submit bugs. Otherwise, use this:
    http://www.apple.com/feedback/iphone.html

  • I just sold my iPhone 4s after doing a reset and deleting data and settings. Is there anyway the buyer can see any of my old photos, texts, or data? I have confidential info for work and family photos and freaked out that they can be found somehow.

    I just sold my iPhone 4s after doing a reset and deleting data and settings. Is there anyway the buyer can see any of my old photos, texts, or data? I have confidential info for work and family photos and freaked out that they can be found somehow.

    No, but if the answer was yes it's a little late to start getting freaked out about it.

Maybe you are looking for