fork(3) download
  1. import java.text.DateFormat;
  2. import java.text.ParseException;
  3. import java.text.SimpleDateFormat;
  4. import java.util.Calendar;
  5. import java.util.Date;
  6. import java.util.Locale;
  7.  
  8. /* The class name doesn't have to be Main, as long as the class is not public. */
  9. class Main
  10. {
  11. public static void main (String[] args) throws java.lang.Exception
  12. {
  13. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MMMM dd, yyyy", Locale.ENGLISH);
  14. SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyyMMdd");
  15. Date date1 = simpleDateFormat.parse("August 21, 2012");
  16. String formattedDate = simpleDateFormat1.format(date1); // 20120821
  17. Date parsedDate = simpleDateFormat1.parse(formattedDate);
  18. System.out.println(formattedDate);
  19. }
  20. }
Success #stdin #stdout 0.05s 246080KB
stdin
Standard input is empty
stdout
20120821