java实现日期选择器,日期和时间选择器在java

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值