开发者

How to convert "9:00 PM EST" to a Date object

开发者 https://www.devze.com 2022-12-26 07:39 出处:网络
I am developing an Android application and require some basic datetime manipulation. I have a Date object (from Java.util.Date) holding a specific date. I need to add a specific time to it. The time I

I am developing an Android application and require some basic datetime manipulation. I have a Date object (from Java.util.Date) holding a specific date. I need to add a specific time to it. The time I have is a s开发者_如何学运维tring in this format: "9:00 PM EST"

How would I "add" this time to the previous date? If the Date object currently has: "4/24/10 00:00:00"

How would I change it to instead be: "4/24/10 09:00:00 EST"

I would prefer to do this without the use of an external library, if possible.


Use SimpleDateFormat with format as "K:mm a vvv". The parse function will return you the date object.

0

精彩评论

暂无评论...
验证码 换一张
取 消