1

検索中に、問題に関する情報を入手したいと思います。

現在の日付で 3 か月を減算したいので、通常は次のようになります。

##set($user.end = $date.format("yyyy-MM-dd", $date.date)) 
##set($user.begin = "${user.end}-03") 

しかし、私は何も回復しません。

私はそれを試します:

##set($R = $date.format("yyyy-MM", $date.date))
##set($query.end = $R)
##set($user.begin = "${R}-03")
#set($query.end = $date.format("yyyy-MM", $date.date))

しかし、私には何もありません。何かアドバイスがあれば教えてください。

エール。

4

2 に答える 2

0

Joda-Timeでは、この種の計算を日時で行う方が簡単です。

Java 7 で Joda-Time 2.3 を使用したソース コードの例:

// © 2013 Basil Bourque. This source code may be used freely forever by anyone taking full responsibility for doing so.

org.joda.time.DateTimeZone losAngelesTimeZone = org.joda.time.DateTimeZone.forID("America/Los_Angeles");
org.joda.time.DateTime november15 = new org.joda.time.DateTime(2013, 11, 15, 18, 0, losAngelesTimeZone);
org.joda.time.DateTime threeMonthsPrior = november15.minusMonths(3);

System.out.println("november15: " + november15);
System.out.println("threeMonthsPrior: " + threeMonthsPrior);

実行すると… (夏時間 (DST)を超えたことに注意してください。-8 対 -7)

november15: 2013-11-15T18:00:00.000-08:00
threeMonthsPrior: 2013-08-15T18:00:00.000-07:00

Joda-Time と関連する問題について…</p>

// Joda-Time - The popular alternative to Sun/Oracle's notoriously bad date, time, and calendar classes bundled with Java 7 and earlier.
// http://www.joda.org/joda-time/

// Joda-Time will become outmoded by the JSR 310 Date and Time API introduced in Java 8.
// JSR 310 was inspired by Joda-Time but is not directly based on it.
// http://jcp.org/en/jsr/detail?id=310

// By default, Joda-Time produces strings in the standard ISO 8601 format.
// https://en.wikipedia.org/wiki/ISO_8601

// About Daylight Saving Time (DST): https://en.wikipedia.org/wiki/Daylight_saving_time

// Time Zone list: http://joda-time.sourceforge.net/timezones.html
于 2013-11-08T23:35:34.913 に答える