12 个回答
OK. I still think using maps to look up the start and end times is the way to go. You'll have to add your 6th value to the maps, as you didn't post it.<pre>public static Map<String,String> startTimes = new Map<String,String>{ '08:00 - 10:00 AM' => '8 AM', '10:00 - 12:00 AM' => '10 AM', '01:00 - 02:00 PM' => '1 PM', '02:00 - 03:00 PM' => '2 PM', '03:00 - 04:00 PM' => '3 PM'};public static Map<String,String> endTimes = new Map<String,String>{ '08:00 - 10:00 AM' => '10 AM', '10:00 - 12:00 AM' => '12 AM', '01:00 - 02:00 PM' => '2 PM', '02:00 - 03:00 PM' => '3 PM', '03:00 - 04:00 PM' => '4 PM'};String timeFrame = recordA.TimeFrame__c.substringBefore( ';' ); recordB.StartTime__c = startTimes.get( timeFrame );recordB.EndTime__c = endTimes.get( timeFrame );</pre>