格式化日期2/24为“2月24日” [英] Formatting date 2/24 as "February, 24"
本文介绍了格式化日期2/24为“2月24日”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
public void printAlphabetical()
{
int month,day; //我从我的程序中获得了用户的月份和日期
String s = String.format(%B,%02d%n,month,day);
日期日期=新日期();
date.parse(s); //这不起作用
System.out.printf(s);
$ / code>
解决方案
String [] month = {Jan,Feb,Mar,Apr,May,Jun,
Jul,Aug,Sep十月,十一月,十二月}
System.out.println(months [month - 1] +,+ day);
I am trying t make a date that comes in like this mm/dd turn into the name of the month and day like it comes in 8/15 i want it to say 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);
}
解决方案
String[] months = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}
System.out.println(months[month - 1] + ", " + day);
这篇关于格式化日期2/24为“2月24日”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文