この文章は Salesforce 機械翻訳システムを使用して翻訳されました。詳細はこちらをご参照ください。
英語に切り替える

BusinessHours クラス

BusinessHours メソッドを使用して、カスタマーサポートチームが活動する営業時間を設定します。

名前空間

System

BusinessHours メソッド

BusinessHours のメソッドは次のとおりです。すべてのメソッドが静的です。

add(businessHoursId, startDate, intervalMilliseconds)

開始時の datetime からの間隔を追加して、営業時間のみを辿ります。結果の datetime をローカルタイムゾーンで返します。

署名

public static Datetime add(String businessHoursId, Datetime startDate, Long intervalMilliseconds)

パラメータ

businessHoursId
型: String
startDate
型: Datetime
intervalMilliseconds
型: Long
間隔値はミリ秒単位で指定する必要がありますが、1 分よりも細かい精度は無視されます。

戻り値

型: Datetime

addGmt(businessHoursId, startDate, intervalMilliseconds)

開始時の datetime からの間隔をミリ秒単位で追加して、営業時間のみを辿ります。結果の datetime を GMT で返します。

署名

public static Datetime addGmt(String businessHoursId, Datetime startDate, Long intervalMilliseconds)

パラメータ

businessHoursId
型: String
startDate
型: Datetime
intervalMilliseconds
型: Long

戻り値

型: Datetime

diff(businessHoursId, startDate, endDate)

特定の営業時間のセットの開始と終了の datetime の差異を返します。

署名

public static Long diff(String businessHoursId, Datetime startDate, Datetime endDate)

パラメータ

businessHoursId
型: String
startDate
型: Datetime
endDate
型: Datetime

戻り値

型: Long

isWithin(businessHoursId, targetDate)

指定された目標日が営業時間内にある場合、true を返します。休日は計算に含まれます。

署名

public static Boolean isWithin(String businessHoursId, Datetime targetDate)

パラメータ

businessHoursId
型: String
営業時間 ID です。
targetDate
型: Datetime
検証する日付です。

戻り値

型: Boolean

次の例では、指定された時間がデフォルトの営業時間内にあるかどうかを調べています。

1// Get the default business hours
2BusinessHours bh = [SELECT Id FROM BusinessHours WHERE IsDefault=true];
3
4// Create Datetime on May 28, 2013 at 1:06:08 AM in the local timezone.
5Datetime targetTime = Datetime.newInstance(2013, 5, 28, 1, 6, 8);
6
7// Find whether the time is within the default business hours
8Boolean isWithin= BusinessHours.isWithin(bh.id, targetTime);

nextStartDate(businessHoursId, targetDate)

指定された目標日以降の、次に営業時間が開始する日付を返します。指定された目標日が営業時間内にある場合、この目標日が返されます。

署名

public static Datetime nextStartDate(String businessHoursId, Datetime targetDate)

パラメータ

businessHoursId
型: String
営業時間 ID です。
targetDate
型: Datetime
次の日付を取得するための開始日として使用される日付です。

戻り値

型: Datetime

次の例では、目標日以降で、次に営業時間が再開する日付を調べています。目標日が所定の営業時間内にある場合、その目標日が返されます。返される時間は、ローカルタイムゾーンの時間になります。

1// Get the default business hours
2BusinessHours bh = [SELECT Id FROM BusinessHours WHERE IsDefault=true];
3
4// Create Datetime on May 28, 2013 at 1:06:08 AM in the local timezone.
5Datetime targetTime = Datetime.newInstance(2013, 5, 28, 1, 6, 8);
6// Starting from the targetTime, find the next date when business hours reopens. Return the target time.
7
8// if it is within the business hours. The returned time will be in the local time zone
9Datetime nextStart = BusinessHours.nextStartDate(bh.id, targetTime);