Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4175879

Your SimpleDateFormat example has 3 errors

XMLWordPrintable

    • merlin
    • generic, x86
    • generic, windows_nt



      Name: dg70945 Date: 09/23/98


      In this code, you have 3 errors:

      SimpleTimeZone pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, "PST");
      pdt.setStartRule(DateFields.APRIL, 1, DateFields.SUNDAY, 2*60*60*1000);
      pdt.setEndRule(DateFields.OCTOBER, -1, DateFields.SUNDAY, 2*60*60*1000);

      ERROR #1 DateFields should be Calendar

      // Format the current time.
      SimpleDateFormat formatter
          = new SimpleDateFormat ("yyyy.mm.dd e 'at' hh:mm:ss a zzz");

      ERROR #2 'e' should be 'E'
      ERROR #3 'mm' should be 'MM'

      Date currentTime_1 = new Date();
      String dateString = formatter.format(currentTime_1);
      // Parse the previous string back into a Date.
      ParsePosition pos = new ParsePosition(0);
      Date currentTime_2 = formatter.parse(dateString, pos);

      GENE McKENNA

            nlindenbsunw Norbert Lindenberg (Inactive)
            dgreensunw Dale Green (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: