Java日期格式真的很简单 [英] Java date format real simple
本文介绍了Java日期格式真的很简单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我有一个日期,我会怎么写te日期,我想要的是像这样的月份和日期(mm / dd),然后像今年7月那样转动月份
how would you write te date if i have a date and all i want is the month and the day like this (mm/dd) and then turn the month like this July, 08
推荐答案
让我看看我是否理解得很好。
Let me see if I understood well.
你有一个像07/08这样的日期而你想要7月8日吗?
You have a date like "07/08" and you want "July, 08"?
你可以尝试 SimpleDateFormat
import java.text.SimpleDateFormat;
import java.text.ParseException;
class Test {
public static void main( String [] args ) throws ParseException {
SimpleDateFormat in = new SimpleDateFormat("MM/dd");
SimpleDateFormat out = new SimpleDateFormat("MMMM, dd");
System.out.println( out.format( in.parse("07/08") ) );
// Verbose
//String input = "07/09";
//Date date = in.parse( input );
//String output = out.format( date );
//System.out.println( output );
}
}
这篇关于Java日期格式真的很简单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文