アーカイブされた日付関数

プラットフォームについて: Data Center のみ。 - この記事は、 Data Center プラットフォーム

この KB は Data Center バージョンの製品用に作成されています。Data Center 固有ではない機能の Data Center KB は、製品のサーバー バージョンでも動作する可能性はありますが、テストは行われていません。 Server* 製品のサポートは 2024 年 2 月 15 日に終了しました。Server 製品を実行している場合は、 アトラシアン Server サポート終了 のお知らせにアクセスして、移行オプションを確認してください。

*Fisheye および Crucible は除く

要約

2018 年 11 月 (server4.1.5) より前にサーバーで作成されたルールがある場合、これを利用できます。クラウドを使用している場合は該当しません。

日付の関数と属性は、日付参照 セクションにあります。

警告

次の構文は引き続き機能しますが、新しい日付構文を使用することを強くお勧めします。簡単に使用できるだけでなく、より強力で多くのバグが修正されています。

Jira の自動化では、スマート値、作成日、更新日、期日、解決日をサポートするフィールドや、日付ピッカー カスタム フィールド ({{issue.MyDateFieldName}}または{{issue.customfield_12356}}) 内で日付の形式を設定できます。

ソリューション

日付の形式は、次の 2 つの方法で指定できます。

形式の指定

1 2 3 4 5 6 7 8 9 // To format a date field value {{#issue.resolutiondate}}longDateTime{{/}}{{#issue.MyDateFieldName}}longDateTime{{/}} // When no other fields are specified, you can include the format {{#now}}longDateTime{{/}} // When you specify timezone or a function to manipulate the date you need // to explicitly label the format and include the value in double quotes {{#now}}format="longDateTime",zone=Australia/Sydney{{/}}

ビルトインの形式が多数あるうえに、独自の形式も指定できます。

形式

1979 年 11 月 1 日 6:23:12 AM EST

注意

初期設定 (指定なし)

Nov 1, 1979 6:23:12 AM

形式が指定されていない場合、初期設定は mediumDateTime です。これは、一部のフィールドの入力として使用すると機能しない可能性があります

toMillis

310303392034

これは次からの経過時間 (ミリ秒) です。

Epoch

toSeconds (秒)

310303392

これは経過時間 (秒) です。

Epoch

toMinutes (分)

5171723

これは経過時間 (分) です。

Epoch

toHours

86195

これは経過時間 (時間) です。

Epoch

toDays

3591

これは経過日数です。

Epoch

タイム ゾーン

初期設定では、日付をタイム ゾーン「UTC」で表示します。これは OnDemand/Cloud 用の Jira サーバーのタイム ゾーンであり、スケジュールされたトリガーの割り当て時に使用する初期設定のタイムゾーンです。別のタイムゾーンを指定するには、パラメーターを追加する必要があります。

1 2 //Prints the time in Sydney when the issue was created. {{#issue.created}}zone=Australia/Sydney{{/}}

タイムゾーンは Joda のドキュメントに記載されています。

ユーザーのタイムゾーンを指定します。

1 2 // Prints the time in the reporters time zone. {{#issue.created}}zone={{reporter.timeZone}}{{/}}

言語 (ロケール)

初期設定では、日付は英語です。別のロケールを指定するには、パラメーターを指定します。

1 2 // Prints the time in Sydney when the issue was created. {{#issue.created}}locale=ru_RU{{/}}

利用可能なロケールは Java のドキュメントに記載されています。

日付の操作

日付の一部を設定するか、そこから値を加算/減算することで、日付を操作します。

1 2 3 4 5 6 // Adds 7 days to the current time {{#now}}func=plusDays(7){{/now}} // You can chain functions. // Sets the day to the first of November {{#issue.created}}func=withDayOfMonth(1).withMonthOfYear(11){{/}}

営業日の計算

営業日を操作するために 2 つの関数が組み込まれています。現在の日付からプラス/マイナスの営業日を指定するか、現在の日付に最も近い営業日を見つけられます。

1 2 3 4 5 6 7 8 9 10 11 12 // The next business day {{#now}}func=toBusinessDay(){{/}} // The next business day after 3 days {{#now}}func=plusDays(3).toBusinessDay(){{/}} // The previous business day {{#now}}func=toBusinessDayBackwards(){{/}} // Adds 6 business days to today {{#now}}func=plusBusinessDays(6){{/}} // The number of business days between when the issue was created and today {{#now}}func=businessDaysBetween({{issue.created}}), format="toDays"{{/}}

2 つの日付の差異を計算する

"toSecond" 形式と "minusSeconds" 関数によって、ある日付をもう一方の日付から減算します。次に、秒数、分数、時間数、または日数を表示する形式のいずれかを使用します。また、より簡単な構文を持つ daysBetween と呼ばれるショートカット メソッドもあります。

1 2 3 4 5 // The number of hours since an issue was created {{#now}}func=minusSeconds({{#issue.created}}toSeconds{{/}}), format="toHours"{{/}} // The number of days between two dates {{#now}}func=daysBetween({{issue.created}}), format="toDays"{{/}}

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 // May 1st this year {{#now}}func=withDayOfMonth(1).withMonthOfYear(5){{/}} // May 1st next year {{#now}}func=withDayOfMonth(1).withMonthOfYear(5).plusYears(1){{/}} // Last day of May {{#now}}func=withDayOfMonth(1).withMonthOfYear(6).minusDays(1){{/}} // First business day in May {{#now}}func=withDayOfMonth(1).withMonthOfYear(5).toBusinessDay(){{/}} // Last business day in May {{#now}}func=withDayOfMonth(1).withMonthOfYear(6).minusDays(1) .toBusinessDayBackwards(){{/}}

更新日時: 2024年05月31日)

さらにヘルプが必要ですか?

アトラシアン コミュニティをご利用ください。