1 package com.calipso.reportgenerator.reportcalculator; 2 3 import com.calipso.reportgenerator.reportdefinitions.types.ReportDataType; 4 import com.calipso.common.DateEx; 5 6 import java.text.SimpleDateFormat ; 7 import java.util.Date ; 8 9 16 public class SharedDateFactory { 17 18 19 public SharedData newSharedDateFromStringSimpleValue(ReportDataType type, String simpleValue){ 20 switch(type.getType()){ 21 case ReportDataType.DATE_TYPE: 22 case ReportDataType.DATETIME_TYPE: 23 SimpleDateFormat format = new SimpleDateFormat ("yyyyMMdd"); 24 Date date = null; 25 try{ 26 date = format.parse(simpleValue); 27 }catch (Exception e){ 28 e.printStackTrace(); 30 } 31 return SharedDate.newFrom(new DateEx(date)); 32 case ReportDataType.STRING_TYPE: 33 return SharedString.newFrom(simpleValue); 34 case ReportDataType.BOOLEAN_TYPE: 35 return SharedBoolean.newFrom(new Boolean (simpleValue)); 36 case ReportDataType.INTEGER_TYPE: 37 return SharedInteger.newFrom(Integer.valueOf(simpleValue)); 38 case ReportDataType.FLOAT_TYPE: 39 return SharedFloat.newFrom(Float.valueOf(simpleValue)); 40 } 41 return null; 42 43 44 } 45 46 47 } 48 | Popular Tags |