#navi(contents-page-name): No such page: ST

FrontPage

Terai Atsuhiro 2021-04-14 (水) 04:00:58

http://terai.s55.xrea.com/swing/timezone/screenshot.png

  final SimpleDateFormat format = 
    new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z", Locale.US);
  final DateFormat df = DateFormat.getDateTimeInstance();
  field.setText("Mon, 19 Apr 2004 16:31:41 +0900");
  outf.setEditable(false);
  df.setTimeZone(TimeZone.getTimeZone("JST"));

    public void actionPerformed(ActionEvent e){
      String str = field.getText().trim();
      ParsePosition pp = new ParsePosition(0);
      Date date = format.parse(str, pp);
      if(date!=null){
        outf.setText(df.format(date));
      }else{
        outf.setText("error");
        Logger.global.info(pp.toString());
      }
    }
  });