Bug 269535

Summary: Unable to execute class, but no compilation issues
Product: [Eclipse Project] JDT Reporter: Christophe Elek <celek>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: VERIFIED INVALID QA Contact:
Severity: normal    
Priority: P3 CC: Olivier_Thomann, srikanth_sankaran
Version: 3.4.2   
Target Milestone: 3.5 M7   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Christophe Elek CLA 2009-03-20 11:13:37 EDT
in my class , if I have the following line

private static final SimpleDateFormat formatter = new SimpleDateFormat("DD HH:mm:ss SSSS'm's'");

I am getting a exception in initializer when running the main

this line allows me to run my main

private static final SimpleDateFormat formatter = new SimpleDateFormat("DD HH:mm:ss SSSS");

I believe the compiler should give me an error about the 'm's' no ?
Comment 1 Olivier Thomann CLA 2009-03-20 11:18:45 EDT
I guess:
private static final SimpleDateFormat formatter = new SimpleDateFormat("DD
HH:mm:ss SSSS'm's'");
is all on one line ?
Comment 2 Olivier Thomann CLA 2009-03-20 11:26:48 EDT
Is this the SimpleDateFormat class for icu or java.text ?
It looks like this constructor can potentially throw an exception.
So the code should rather be:
private static final SimpleDateFormat formatter = newFormatter();
private static SimpleDateFormat newFormatter() {
	SimpleDateFormat current = null;
try {
  current = new SimpleDateFormat("DDHH:mm:ss SSSS'm's'");
} catch(IllegalArgumentException e) {
  // handle exception
}
return current;
}

It is not up to the compiler to check the validity of the pattern.
Closing as INVALID.
Comment 3 Christophe Elek CLA 2009-03-20 11:32:23 EDT
Yes one line, so the String is valid 'm's' ? This is an exception at runtime ?
Comment 4 Srikanth Sankaran CLA 2009-04-28 03:56:29 EDT
Verified to be invalid.