开发者

Java Date conversion [duplicate]

开发者 https://www.devze.com 2023-03-07 08:13 出处:网络
开发者_运维知识库This question already has answers here: Closed 11 years ago. Possible Duplicate:
开发者_运维知识库This question already has answers here: Closed 11 years ago.

Possible Duplicate:

Java string to date conversion

Hi, how would I convert a string, for example "5/22/2011" into Sunday, May 22?

Thanks in advance!


Try:

Date d = new SimpleDateFormat("MM/dd/yyyy").parse("5/22/2011");
String s = new SimpleDateFormat("EEEE, MMMM dd").format(d);


Take a look at the class SimpleDateFormat The javadoc give a good description of the parameters

You can use one format to convert into a java Date object and then another to convert back into the second string

0

精彩评论

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