I am very new to java and I want user to input time and date on which a football match needs to be scheduled. I'm using SWING jForm as the interface. After getting that date I also want to put that in the database. After searching a lot either I couldn't search the right code or I can't understand that. I'm working on a pretty long project and left with no time to watch tutorial. Any help in this regard would be very highly appreciated.
Or just tell me if I have "YYYY/MM/DD HH:MM:ss:SSS" in a String then how can I convert that to Date format?
Date d = (Date)dateString didn't worked.
Note I am using drag and drop to create items on jFrame.
解决方案
(a) Doing date-time work at the last minute is a bad idea. Date-time can be a surprisingly thorny topic.
(b) See my answer to a similar question.
My example code there uses the third-party library Joda-Time, a popular replacement for the notoriously bad java.util.Date/Calendar classes bundled with Java.
That code is just what you need, though you'll need to:
Adjust the format to your particular needs
Adjust the time zones to whatever you are handling
Do most of your date-time work within the Joda-Time framework. At the beginning and end, convert between Joda-Time DateTime objects and java.util.Date objects. Lots of Q&A here on StackOverflow to show you that conversion.