Jira スマート バリュー - 日時

スマート値をサポートするフィールド内で、作成日更新日期限解決日のフィールド、および日付ピッカーのカスタム フィールドを操作してフォーマットできます。

On this page:


日付と時刻のスマート値

日付と時間の各フィールドにアクセスして形式を設定するには、次のスマート値を利用します。

現バージョン

現在の日時を参照するスマート値

{{now}}
{{now.plusDays(7).jqlDate}}

例:

// 1st of May this year
{{now.startOfMonth.withMonth(5)}}

// 1st of May next year
{{now.startOfMonth.withMonth(5).plusYears(1)}}

// last day of May
{{now.withMonth(5).endOfMonth}}

// first business day in May
{{now.withMonth(5).firstBusinessDayOfMonth}}

// last business day in May
{{now.withMonth(5).lastBusinessDayOfMonth}}

日付形式

例:

{{now.jiraDate}}
{{now.format("dd/MM/yyyy")}}
{{now.shortDate}}
形式1979 年 11 月 1 日、木曜日、6:23:12 AM EST
初期設定 (指定なし)1979 年 11 月 1 日、6:23:12 AM
jiraDate1979-11-01
jiraDateTime1979-11-01T06:23:12.0-0500
jqlDate1979-11-01
jqlDateTime1979-11-01 06:23
shortDate11/1/79
shortTime6:23 AM
shortDateTime11/1/79 6:23 AM
mediumDate1979 年 11 月 1 日
mediumTime6:23:12 AM
mediumDateTime1979 年 11 月 1 日、6:23:12 AM
longDate1979 年 11 月 1 日
longTime6:23:12 AM EST
longDateTime1979 年 11 月 1 日、6:23:12 AM EST
fullDateThursday, November 1, 1979
fullTime6:23:12 AM EST
fullDateTime1979 年 11 月 1 日、木曜日、6:23:12 AM EST
format("<pattern>") 例: format("dd/MM/yyyy")

パターン構文については Java のドキュメントをご参照ください。
01/11/1979

diff(date)

{{now.diff(issue.created).days}}

利用可能なユニット:

  • millis
  • minutes
  • days
  • weeks
  • businessDays
  • prettyPrint
  • abs

「prettyPrint」は単語間の差分を表示します。例: 2 days 3 hours

isAfter(date)

{{now.isAfter(issue.created)}} (true または false を返す)

isBefore(date)

{{now.isBefore(issue.created)}} (true または false を返す)

isEquals(date)

{{now.isEquals(now)}} (true または false を返す)

compareTo(date)

{{now.compareTo(issue.created)}} (数値を返す)
{{issue.created.compareTo(now)}}
(数値を返す)
{{now.compareTo(now)}}
(0 を返す)

plusDays/minusDays

{{now.plusDays(1)}}
{{now.minusDays(1)}}

plusHours/minusHours

{{now.plusHours(1)}}
{{now.minusHours(1)}}

plusWeeks/minusWeeks

{{now.plusWeeks(1)}}
{{now.minusWeeks(1)}}

plusMillis/minusMillis

{{now.plusMillis(1)}}
{{now.minusMillis(1)}}

plusMinutes/minusMinutes

{{now.plusMinutes(1)}}
{{now.minusMinutes(1)}}

plusMonths/minusMonths

{{now.plusMonths(1)}}
{{now.minusMonths(1)}}

plusSeconds/minusSeconds

{{now.plusSeconds(1)}}
{{now.minusSeconds(1)}}

plusYears/minusYears

{{now.plusYears(1)}}
{{now.minusYears(1)}}

plusBusinessDays/minusBusinessDays

営業日は月~金の午前 9 時 ~ 午後 6 時とします。

{{now.plusBusinessDays(1)}}
{{now.minusBusinessDays(1)}}

toBusinessDay/toBusinessDayBackwards

営業日は月~金の午前 9 時 ~ 午後 6 時とします。

{{toBusinessDay}}
{{toBusinessDayBackwards}}

setTimeZone/convertToTimeZone

{{convertToTimeZone("Australia/Sydney")}}
時刻を新しいタイムゾーンの時刻に変換します。たとえば、UTC 午前 7 時はシドニー時間の午後 5 時になります。これは、特定のタイムゾーンで日付を表示、または特定のタイムゾーンの時間に基づいて計算を実行する際に役立ちます。

{{setTimeZone("Australia/Sydney")}}
タイムゾーンを変更しますが、同じ日時を維持します。例: UTC 午前 7 時をシドニー時間午前 7 時に変換

注: タイムゾーンは {area}/{city} フォーマットで指定する必要があります (例: America/Los_Angeles)。

タイム ゾーンのリストについては、Java ドキュメントを参照してください

日付から日時への変換

次の関数によって、日付を時間コンポーネントを含む日付に変換できます。

{{now.toStartOfDay}}
{{now.toCurrentTime}}
{{now.toDateTimeAtStartOfDay}}
{{now.toDateTimeAtStartOfDay(timezone)}}
{{now.toDateTimeAtCurrentTime}}
{{now.toDateTimeAtCurrentTime(timezone)}}

withDayOfMonth

{{now.withDayOfMonth(15)}}

withNextDayOfWeek

日付を次の当該曜日に設定します。
すでにその曜日である場合は、翌週の曜日を返します。
使用できる値は、MON、TUE、WED、THU、FRI、SAT、SUN です。

{{now.withNextDayOfWeek("TUE")}}  は次の火曜日を返します。
{{now.withNextDayOfWeek("MON").withHour(14).withMinute(0)}} は次の月曜日の午後 2 時を返します。

withHour

{{now.withHour(20)}}

withMillis

{{now.withMillis(500)}}

withMinute

{{now.withMinute(59)}}

withMonth

{{now.withMonth(10)}}

withSecond

{{now.withSecond(0)}}

withYear

{{now.withYear(1979)}}

withDayOfYear

{{now.withDayOfYear(355)}}

日付の曜日コンポーネントを設定します

{{now.endOfMonth}}
{{now.startOfMonth}}
{{now.firstBusinessDayOfMonth}}
{{now.lastBusinessDayOfMonth}}

// Parameters: day of week (1-7) 
{{now.firstOfTheMonth(1)}}
{{now.lastOfTheMonth(1)}}

// Parameters: nth of month (1-5), day of week (1-7)
{{now.ofTheMonth(2, 1)}}

属性

課題が作成された月や曜日など、その日の個々の属性を取得できます。以下に例を示します。

// Get today's day of the month
{{now.dayOfMonth}}
 
// Get the day of the week the issue was created
{{issue.created.dayOfWeekName}}

// Get the day name of the week in French
{{issue.created.locale("fr").dayOfWeekName}}
属性
millis
second
時間
monthOfYear
dayOfYear
dayOfWeek
dayOfWeekName
dayOfWeekShortName
weekOfYear
zoneId
toDays
isLeapYear
lengthOfMonth
lengthOfYear
timeZoneShort
timeZoneFull
timeZoneNarrow
offsetShort
offsetFull
offsetNarrow

日付と時刻に関連するスマート値の使用例

日付と時刻に関連してスマート値を使用する例をいくつか確認してください。

日付をフォーマットする

スマート値の末尾に日付の形式を指定します。 

// using inbuilt formats
{{issue.resolutiondate.asLongDateTime}}
{{issue.MyDateFieldName.longDateTime}}
{{issue.created.jqlDateTime}}
{{issue.created.mediumTime}}
{{issue.Sprint.endDate.jiraDate}} - format the Sprint field's end date into a format suitable to set another field

// Or, you can specify the format
{{issue.dueDate.format("dd/MM/yyyy")}}
{{issue.created.as("dd MMM")}}


ロケール (位置に基づく日付形式)

印刷する日付のロケールを指定します (初期設定は「US」ロケールです)。 

// Prints the issue's created date in French
{{issue.created.withLocale("fr").asLongDateTime}}

// Prints the issue's created date in French Canadian
{{issue.created.locale("fr_CA").longDateTime}}

// Prints the issue's created date in the locale of the reporter
{{issue.created.locale(issue.reporter.locale).longDateTime}}

ロケールのリストについては、Java ドキュメントをご参照ください

タイム ゾーン

日付は Jira の初期設定のタイムゾーンで表示されます。

// Converts the issue's created time to the new time zone, 
// e.g. 10am UTC converts to 8pm AEST
{{issue.created.convertToTimeZone("Australia/Sydney")}}

// Converts the issue's created time to the new time zone and keeps the same
// times/dates. E.g. 10am UTC changes to 10am AEST
{{issue.created.setTimeZone("Australia/Sydney")}}

タイムゾーンのリストは、Java ドキュメントをご参照ください。

ユーザーのタイムゾーンを指定する

// Prints the issue's created time in the reporters time zone.
{{issue.created.convertToTimeZone(issue.reporter.timeZone)}}

日付の操作

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

// Add 7 days to the current time
{{now.plusDays(7)}}
 
// You can chain functions
// Set the created date to November 1st
{{issue.created.withDayOfMonth(1).withMonth(11)}}

営業日の計算

現在の日付から営業日を増減するか、現在の日付に最も近い営業日を見つけます。営業日は月曜日から金曜日とします。

// The next business day
{{now.toBusinessDay()}}

// The next business day after 3 days
{{now.plusDays(3).toBusinessDay()}}

// The previous business day
{{now.toBusinessDayBackwards()}}

// Adds 6 business days to today
{{now.plusBusinessDays(6)}}

// The first business day of the month
{{now.firstBusinessDayOfMonth}}

// The last business day of the month
{{now.lastBusinessDayOfMonth}}

// The number of business days beeween when the issue was created and today
{{now.diff(issue.created).businessDays}}

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

「diff」メソッドは別の日付に渡してから測定する単位を指定することで、2 つの日付の差異を計算します。

// Gets how many hours since an issue was created
{{now.diff(issue.created).hours}}

// Gets the number of days between two dates
{{now.diff(issue.created).days}}

// To show positive dates use the "abs" method
{{now.diff(issue.created).abs.days}}

2 つの日付を比較する

2 つの日付を比較できます。これらのメソッドは、別の日付をパラメーターとして取得します。

// Returns "true"
{{now.isAfter(issue.created)}}
tip/resting Created with Sketch.

比較条件によって日付を比較します

テキストを日付に変換する

正しい書式の場合はテキストを日付に変換します。パラメーターを追加することで、どの書式から変換するかを指定できます。次のスマート値を使って、さまざまなテキスト形式を日付オブジェクトに変換できます。

  • 「2024 10 20」のようなテキストを日付に変換するには、このスマート値を使用します。
    {{issue.summary.toDate("yyyy MM dd")}}
  • 「10/20/2024」のようなテキストを日付に変換するには、このスマート値を使用します。
    {{issue.summary.toDate("MM/dd/yyyy")}}
  • 「20/10/2024」のようなテキストを日付に変換するには、このスマート値を使用します。
    {{issue.summary.toDate("dd/MM/yyyy")}}

 テキストを日付オブジェクトに変換した後に、フィールドの変更など、そのオブジェクトをさらに変換する必要がある場合があります (例: 日付の変更をリッスンする場合)。

{{fieldChange.fromString.toDate.plusDays(1).longDate}}
最終更新日 2025 年 4 月 24 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.