【发布时间】:2013-04-09 12:56:09
【问题描述】:
我有 4 位数字的日期。我遇到了 2050 年之后的输入。在我的应用程序中 "0150" 表示 January 01 2050。但是当我格式化它会返回以下输出。
Sun Jan 01 00:00:00 PKT 1950
public static Date getFormatDate( String newformat, String dateValue ) throws Exception {
try {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat( newformat );
java.util.Date newdate = simpleDateFormat.parse( dateValue );
return newdate;
}
catch( Exception e ) {
System.out.println( "Exception in converting date format --->" + e );
throw e;
}
}
public static void main( String[] args ) throws Exception {
System.out.println(getFormatDate( "MMyy", "0150" ));
}
我们将不胜感激任何解决此问题的帮助。
【问题讨论】:
-
才 2013 年,人们已经开始尝试再次削减世纪?
标签: java date date-format simpledateformat