gpt4 book ai didi

java - 将日期 2/24 格式化为 "February, 24"

转载 作者:行者123 更新时间:2023-12-01 17:40:11 24 4
gpt4 key购买 nike

我正在尝试将像这样的 mm/dd 格式的日期变成月份和日期的名称,就像它出现在 8/15 中一样,我希望它显示为 August, 15

public void printAlphabetical()
{
int month,day;// i got the month and day from a user previously in my program

String s = String.format("%B, %02d%n",month,day);
Date date = new Date();
date.parse(s);// this does not work
System.out.printf(s);
}

最佳答案

    System.out.println( new SimpleDateFormat("MMMM, dd").format( 
new SimpleDateFormat("MM/dd").parse("2/24") ) );

嗯,似曾相识?不,完全重复 -> here

关于java - 将日期 2/24 格式化为 "February, 24",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1804000/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com