Loading [MathJax]/extensions/tex2jax.js

2010-08-23

GWTで時間表示

Javaにおいて、時間表示をする際には、
  1. Dateクラスで現在時間を入手
  2. SimpleDateFormatクラスで、表示フォーマットを決定

といった手順をとるのが手っ取り早いが、GWTではSimpleDateFormatが使えない。そこで、com.google.gwt.i18n.client.DateTimeFormatクラスを利用しよう。
詳細は、JavaDocを参照のこと
Date nowTime = new Date();
DateTimeFormat fmt = DateTimeFormat.getFormat("yyyy/MM/d/h:mm");
Window.alert(fmt.format(nowTime));


0 件のコメント:

コメントを投稿