Package org.iplass.mtp.util
Class DateUtil
java.lang.Object
org.iplass.mtp.util.DateUtil
日付操作用のユーティリティです。
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Calendar
getCalendar
(boolean useTenantTimeZone) static Calendar
getCalendar
(Locale locale, boolean useTenantTimeZone) static Date
テナントローカルの現在日付を返します。
同一リクエスト処理中は常に同じ値(リクエスト処理中に最初に当該メソッドが呼ばれた日付)を返します。
現在日付をjava.sql.Dateで表現するためのものです。 システムのタイムゾーンとテナントローカルタイムゾーンが異なる場合、タイムゾーンのオフセット分シフトされた値となります。static Time
テナントローカルの現在時間を返します。
同一リクエスト処理中は常に同じ値(リクエスト処理中に最初に当該メソッドが呼ばれた日付)を返します。
現在時刻をjava.sql.Timeで表現するためのものです。 1970-01-01 00:00:00~23:59:59の間の値となります。 システムのタイムゾーンとテナントローカルタイムゾーンが異なる場合、テナントローカルのタイムゾーンのオフセット分シフトされた値となります。static Timestamp
現在日時を返します。 同一リクエスト処理中は常に同じ値(リクエスト処理中に最初に当該メソッドが呼ばれた日時)を返します。static ZonedDateTime
現在日時を取得するstatic ZonedDateTime
getCurrentZonedDateTime
(ZoneId zoneId) 指定されたゾーンIDの現在日時を取得するstatic String
getCurrentZonedDateTimeFormat
(DateTimeFormatter formatter) 現在時刻を指定されたフォーマットで取得するstatic ZonedDateTime
getCurrentZonedDateTimeMinus
(Duration duration) 現在時刻から指定された時間を減算した日時を取得するstatic DateFormat
getDateInstance
(int style, boolean useTenantTimeZone) static DateFormat
getDateInstance
(int style, Locale locale, boolean useTenantTimeZone) static DateFormat
getDateTimeInstance
(int dateStyle, int timeStyle, boolean useTenantTimeZone) static DateFormat
getDateTimeInstance
(int dateStyle, int timeStyle, Locale locale, boolean useTenantTimeZone) static DateFormat
getDateTimeInstance
(int dateStyle, int timeStyle, Locale locale, TimeZone timeZone, boolean useTenantTimeZone) static GregorianCalendar
getGregorianCalendar
(boolean useTenantTimeZone) static SimpleDateFormat
getSimpleDateFormat
(String pattern, boolean useTenantTimeZone) 指定のpatternのSimpleDateFormatのインスタンスを取得します。 ロケールは、テナントに設定されるロケール(未設定の場合はシステムデフォルトロケール)が利用されます。static SimpleDateFormat
getSimpleDateFormat
(String pattern, boolean useTenantTimeZone, boolean useUserLangLocale) 指定のpatternのSimpleDateFormatのインスタンスを取得します。static DateFormat
getTimeInstance
(boolean useTenantTimeZone) static DateFormat
getTimeInstance
(int style, boolean useTenantTimeZone) static DateFormat
getTimeInstance
(int style, Locale locale, boolean useTenantTimeZone)
-
Constructor Details
-
Method Details
-
getCurrentTimestamp
現在日時を返します。 同一リクエスト処理中は常に同じ値(リクエスト処理中に最初に当該メソッドが呼ばれた日時)を返します。- Returns:
-
getCurrentDate
テナントローカルの現在日付を返します。
同一リクエスト処理中は常に同じ値(リクエスト処理中に最初に当該メソッドが呼ばれた日付)を返します。
現在日付をjava.sql.Dateで表現するためのものです。 システムのタイムゾーンとテナントローカルタイムゾーンが異なる場合、タイムゾーンのオフセット分シフトされた値となります。- Returns:
-
getCurrentTime
テナントローカルの現在時間を返します。
同一リクエスト処理中は常に同じ値(リクエスト処理中に最初に当該メソッドが呼ばれた日付)を返します。
現在時刻をjava.sql.Timeで表現するためのものです。 1970-01-01 00:00:00~23:59:59の間の値となります。 システムのタイムゾーンとテナントローカルタイムゾーンが異なる場合、テナントローカルのタイムゾーンのオフセット分シフトされた値となります。- Returns:
-
getSimpleDateFormat
指定のpatternのSimpleDateFormatのインスタンスを取得します。 ロケールは、テナントに設定されるロケール(未設定の場合はシステムデフォルトロケール)が利用されます。- Parameters:
pattern
-useTenantTimeZone
- システムのデフォルトタイムゾーンではなく、テナントに設定されるタイムゾーンを利用する場合はtrueを指定します- Returns:
-
getSimpleDateFormat
public static SimpleDateFormat getSimpleDateFormat(String pattern, boolean useTenantTimeZone, boolean useUserLangLocale) 指定のpatternのSimpleDateFormatのインスタンスを取得します。- Parameters:
pattern
-useTenantTimeZone
- システムのデフォルトタイムゾーンではなく、テナントに設定されるタイムゾーンを利用する場合はtrueを指定しますuseUserLangLocale
- テナントに設定されるロケールではなく、当該処理を実行しているユーザーの言語に紐付くロケールを利用する場合はtrueを指定します。- Returns:
-
getCalendar
-
getCalendar
-
getGregorianCalendar
-
getDateInstance
-
getDateInstance
-
getDateTimeInstance
public static DateFormat getDateTimeInstance(int dateStyle, int timeStyle, boolean useTenantTimeZone) -
getDateTimeInstance
public static DateFormat getDateTimeInstance(int dateStyle, int timeStyle, Locale locale, boolean useTenantTimeZone) -
getDateTimeInstance
public static DateFormat getDateTimeInstance(int dateStyle, int timeStyle, Locale locale, TimeZone timeZone, boolean useTenantTimeZone) -
getTimeInstance
-
getTimeInstance
-
getTimeInstance
-
getCurrentZonedDateTime
現在日時を取得するテナントローカルなタイムゾーンの現在日時を取得します。
- Returns:
- 現在日時
-
getCurrentZonedDateTime
指定されたゾーンIDの現在日時を取得する- Parameters:
zoneId
- ゾーンID- Returns:
- 現在日時
-
getCurrentZonedDateTimeMinus
現在時刻から指定された時間を減算した日時を取得するテナントローカルなタイムゾーンの現在日時から、指定された時間を減算します。
- Parameters:
duration
- 減算時間- Returns:
- 減算後の日時
-
getCurrentZonedDateTimeFormat
現在時刻を指定されたフォーマットで取得する- Parameters:
formatter
- 日付時刻フォーマット- Returns:
- フォーマットされた日時文字列
-