Details
-
Bug
-
Status: Closed
-
Critical
-
Resolution: Fixed
-
None
-
None
-
None
Description
The following code fails to compile:
public interface DateTimeFormatConstants { static final SimpleDateFormat AM_PM_TIME_FORMAT = new SimpleDateFormat("h:mma") static final SimpleDateFormat MILITARY_TIME_FORMAT = new SimpleDateFormat("HH:mm") } class DateTimeUtils implements DateTimeFormatConstants { static String convertMilitaryTimeToAmPm(String militaryTime) { Date date = MILITARY_TIME_FORMAT.parse(militaryTime) return AM_PM_TIME_FORMAT.format(date).toLowerCase() } }
The error message is:
You attempted to reference a variable in the binding or an instance variable from a static context. You misspelled a classname or statically imported field. Please check the spelling. You attempted to use a method 'AM_PM_TIME_FORMAT' but left out brackets in a place not allowed by the grammar. @ line 13, column 16. return AM_PM_TIME_FORMAT.format(date).toLowerCase() ^