Newer Version Available
BusinessHours クラス
BusinessHours メソッドを使用して、カスタマーサポートチームが活動する営業時間を設定します。
名前空間
BusinessHours メソッド
BusinessHours のメソッドは次のとおりです。すべてのメソッドが静的です。
add(businessHoursId, startDate, intervalMilliseconds)
開始時の datetime からの間隔を追加して、営業時間のみを辿ります。結果の datetime をローカルタイムゾーンで返します。
署名
public static Datetime add(String businessHoursId, Datetime startDate, Long intervalMilliseconds)
パラメータ
戻り値
型: Datetime
isWithin(businessHoursId, targetDate)
指定された目標日が営業時間内にある場合、true を返します。休日は計算に含まれます。
署名
public static Boolean isWithin(String businessHoursId, Datetime targetDate)
戻り値
型: Boolean
例
次の例では、指定された時間がデフォルトの営業時間内にあるかどうかを調べています。
1swfobject.registerObject("clippy.codeblock-0", "9");
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17// Get the default business hours
18BusinessHours bh = [SELECT Id FROM BusinessHours WHERE IsDefault=true];
19
20// Create Datetime on May 28, 2013 at 1:06:08 AM in the local timezone.
21Datetime targetTime = Datetime.newInstance(2013, 5, 28, 1, 6, 8);
22
23// Find whether the time is within the default business hours
24Boolean isWithin= BusinessHours.isWithin(bh.id, targetTime);nextStartDate(businessHoursId, targetDate)
指定された目標日以降の、次に営業時間が開始する日付を返します。指定された目標日が営業時間内にある場合、この目標日が返されます。
署名
public static Datetime nextStartDate(String businessHoursId, Datetime targetDate)
戻り値
型: Datetime
例
次の例では、目標日以降で、次に営業時間が再開する日付を調べています。目標日が所定の営業時間内にある場合、その目標日が返されます。返される時間は、ローカルタイムゾーンの時間になります。
1swfobject.registerObject("clippy.codeblock-1", "9");
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17// Get the default business hours
18BusinessHours bh = [SELECT Id FROM BusinessHours WHERE IsDefault=true];
19
20// Create Datetime on May 28, 2013 at 1:06:08 AM in the local timezone.
21Datetime targetTime = Datetime.newInstance(2013, 5, 28, 1, 6, 8);
22// Starting from the targetTime, find the next date when business hours reopens. Return the target time.
23
24// if it is within the business hours. The returned time will be in the local time zone
25Datetime nextStart = BusinessHours.nextStartDate(bh.id, targetTime);