3 Replies Latest reply: Apr 1, 2009 1:54 AM by EJP RSS

    Problem with string-representation of Calendar and parsing it


      I hope this is the correct forum for this kind of question.

      I have two machines, one PC and one Notebook with the following setups:

      PC: Windows Vista (32Bit), Java jdk1.6.0_07
      Notebook: Windows XP Home, Java jdk1.6.0_12

      I run the following on both machines:
      Calendar calendar = Calendar.getInstance();
      SimpleDateFormat df = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss.S z" );
      System.out.println( df.format( calendar.getTime() ) );
      // Parse date
      String timeString = "2009-03-31 09:27:47.982 MESZ";
      Date parsedDate = df.parse( timeString );
      calendar.setTime( parsedDate );
      On the notebook, the time string can be parsed without problems. But on the PC, the following exception will be thrown:

      "Exception in thread "main" java.text.ParseException: Unparseable date: "2009-03-31 09:27:47.982 MESZ""

      Besides that, the output of the java program on the PC is like that: "2009-03-31 09:27:47.982 CEST", note the "CEST" instead of the "MESZ".

      Both computers have the same time configuration, e.g. the time zone.

      For me, it is a problem, since I would like to send those string representation to the other computer, which must parse it.

      Do you have any ideas, why there is such a difference?