Warning: include_once(): http:// wrapper is disabled in the server configuration by allow_url_include=0 in /home/users/2/moriya-h5/web/confrage/java/commons/dateutils.html on line 2

Warning: include_once(http://www.confrage.com/bin/header.php): failed to open stream: no suitable wrapper could be found in /home/users/2/moriya-h5/web/confrage/java/commons/dateutils.html on line 2

Warning: include_once(): Failed opening 'http://www.confrage.com/bin/header.php' for inclusion (include_path='.:/usr/local/php/5.6/lib/php') in /home/users/2/moriya-h5/web/confrage/java/commons/dateutils.html on line 2
DateUtils | Java | 株式会社CONFRAGE
Warning: include_once(/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/menu.php): failed to open stream: No such file or directory in /home/users/2/moriya-h5/web/confrage/java/commons/dateutils.html on line 17

Warning: include_once(): Failed opening '/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/menu.php' for inclusion (include_path='.:/usr/local/php/5.6/lib/php') in /home/users/2/moriya-h5/web/confrage/java/commons/dateutils.html on line 17
DateUtils
DateUtilsクラスは、Dateクラスのメソッドを拡張したユーティリティクラスです。
日数を1日足したい場合、addDaysメソッドを使用します。
月を一ヶ月足したい場合や引きたい場合も、addMonthsメソッドを使用します。
日付の計算には非常に便利です。

package jp.co.confrage;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

import org.apache.commons.lang.time.DateUtils;

public class Test004 {

    public static void main(String[] args) {
        Calendar cal1 = Calendar.getInstance();
        cal1.set(2011,0,1);
        Date date = DateUtils.addDays(cal1.getTime(),2);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
        System.out.println(sdf.format(date));
    }
}
実行結果は以下のようになります。

20110103

Back to top

Information

Warning: include_once(/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/side_bar.php): failed to open stream: No such file or directory in /home/users/2/moriya-h5/web/confrage/java/commons/dateutils.html on line 84

Warning: include_once(): Failed opening '/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/side_bar.php' for inclusion (include_path='.:/usr/local/php/5.6/lib/php') in /home/users/2/moriya-h5/web/confrage/java/commons/dateutils.html on line 84

Warning: include_once(/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/seo.php): failed to open stream: No such file or directory in /home/users/2/moriya-h5/web/confrage/java/commons/dateutils.html on line 93

Warning: include_once(): Failed opening '/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/seo.php' for inclusion (include_path='.:/usr/local/php/5.6/lib/php') in /home/users/2/moriya-h5/web/confrage/java/commons/dateutils.html on line 93