Code: Select all
import java.text.*;
import java.util.*;
class DateFormatPlay
{
Calendar c = Calendar.getInstance();
c.set(2012, 11, 25); //christmas day due to zero based indexed month
Locale l = new Locale("it", "IT");
DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM);
System.out.println(df.format(c.getTime()));
}
C:\Documents and Settings\Jon\Desktop\DateFormatPlay.java:6: error: <identifier> expected
c.set(2012, 11, 25); //christmas day due to zero based indexed month
^
C:\Documents and Settings\Jon\Desktop\DateFormatPlay.java:6: error: illegal start of type
c.set(2012, 11, 25); //christmas day due to zero based indexed month
^
C:\Documents and Settings\Jon\Desktop\DateFormatPlay.java:6: error: illegal start of type
c.set(2012, 11, 25); //christmas day due to zero based indexed month
^
C:\Documents and Settings\Jon\Desktop\DateFormatPlay.java:6: error: illegal start of type
c.set(2012, 11, 25); //christmas day due to zero based indexed month
^
C:\Documents and Settings\Jon\Desktop\DateFormatPlay.java:9: error: <identifier> expected
System.out.println(df.format(c.getTime()));
^
C:\Documents and Settings\Jon\Desktop\DateFormatPlay.java:9: error: <identifier> expected
System.out.println(df.format(c.getTime()));
^
C:\Documents and Settings\Jon\Desktop\DateFormatPlay.java:9: error: ';' expected
System.out.println(df.format(c.getTime()));
^
C:\Documents and Settings\Jon\Desktop\DateFormatPlay.java:9: error: illegal start of type
System.out.println(df.format(c.getTime()));
^
C:\Documents and Settings\Jon\Desktop\DateFormatPlay.java:9: error: ';' expected
System.out.println(df.format(c.getTime()));
^
9 errors
Tool completed with exit code 1
Usually when I post this as a bug, the technical support team refuses it, for some reason unknown, so I posted the issue here. The code within Eclipse reads as follows:
Code: Select all
package code;
import java.text.*;
import java.util.*;
class DateFormatPlay
{
public static void main (String[] args)
{ Calendar c = Calendar.getInstance();
c.set(2012, 11, 25); //Christmas Day
Locale l = new Locale("it", "IT");
DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM);
System.out.println(df.format(c.getTime()));
}
}
25-Dec-2012
Is there a way I can re-write this code in single lines, other than writing a function?