Integer クラス
Integer のメソッド
Integer のメソッドは次のとおりです。
format()
コンテキストユーザのロケールを使用して、integer を文字列として返します。
署名
public String format()
戻り値
型: String
例
1integer myInt = 22;
2system.assertEquals('22', myInt.format());valueOf(fieldValue)
指定されたオブジェクトを integer に変換します。このメソッドを使用して、履歴管理項目の値または integer 値を表すオブジェクトを変換します。
署名
public static Integer valueOf(Object fieldValue)
パラメータ
- fieldValue
- 型: Object
戻り値
型: Integer
使用方法
数値項目のように項目のデータ型が integer 型に対応する場合は、AccountHistory など、履歴 sObject の OldValue 項目または NewValue 項目でこのメソッドを使用します。
例:
例
1List<AccountHistory> ahlist =
2 [SELECT Field,OldValue,NewValue
3 FROM AccountHistory];
4for(AccountHistory ah : ahlist) {
5 System.debug('Field: ' + ah.Field);
6 if (ah.field == 'NumberOfEmployees') {
7 Integer oldValue =
8 Integer.valueOf(ah.OldValue);
9 Integer newValue =
10 Integer.valueOf(ah.NewValue);
11}