Groovy-dates-times-tostring

提供:Dev Guides
移動先:案内検索

Groovy-日付と時刻toString()

このDateオブジェクトをフォームの文字列に変換します

ダウモンdd hh:mm:ss zzz yyyy

構文

public String toString()

パラメーター

無し。

戻り値

この日付の文字列表現。

以下は、このメソッドの使用例です-

class Example {
   static void main(String[] args) {
      Date olddate = new Date("05/11/2015");
      Date newdate = new Date("05/11/2015");
      Date latestdate = new Date();

      System.out.println(olddate.toString());
      System.out.println(newdate.toString());
      System.out.println(latestdate.toString());
   }
}

上記のプログラムを実行すると、次の結果が得られます-

Mon May 11 00:00:00 GST 2015
Mon May 11 00:00:00 GST 2015
Thu Dec 10 21:46:18 GST 2015