Java 7 SimpleDataFormat使用JDK7返回空日期,但使用JDK6可以正常工作

Java 7 SimpleDataFormat使用JDK7返回空日期,但使用JDK6可以正常工作,java-7,Java 7,我有这个示例java代码,其中我试图根据SimpleDataFormat上的模式集将字符串解析为日期。当我在JDK6中运行这段代码时,它工作正常。但在JDK7中,解析调用时返回NULL。知道JDK7改变了什么吗。这是一个已知的问题还是解决方法 SimpleDateFormat _theSimpleDateFormatHelper = new SimpleDateFormat(); _theSimpleDateFormatHelper.setLenient(false); _theS

我有这个示例java代码,其中我试图根据SimpleDataFormat上的模式集将字符串解析为日期。当我在JDK6中运行这段代码时,它工作正常。但在JDK7中,解析调用时返回NULL。知道JDK7改变了什么吗。这是一个已知的问题还是解决方法

  SimpleDateFormat _theSimpleDateFormatHelper =  new SimpleDateFormat();
  _theSimpleDateFormatHelper.setLenient(false);
  _theSimpleDateFormatHelper.applyPattern("yyyy-MM-dd hh:mm:ss");

  ParsePosition parsePos = new ParsePosition(0);
  Object formattedObj = _theSimpleDateFormatHelper.parse("1989-09-21 00:00:00", parsePos);

以下代码可以正常工作:

SimpleDateFormat _theSimpleDateFormatHelper =  new SimpleDateFormat();
//_theSimpleDateFormatHelper.setLenient(false); <-- In lenient mode, the parsing succeeds
_theSimpleDateFormatHelper.applyPattern("yyyy-MM-dd hh:mm:ss");

ParsePosition parsePos = new ParsePosition(0);
Object formattedObj = _theSimpleDateFormatHelper.parse("1989-09-21 00:00:00", parsePos);
SimpleDateFormat _theSimpleDateFormatHelper =  new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
_theSimpleDateFormatHelper.setLenient(false);
Object formattedObj = _theSimpleDateFormatHelper.parse("1989-09-21 00:00:00");