KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > calipso > reportgenerator > reportcalculator > SharedDateFactory


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 JavaDoc;
7 import java.util.Date JavaDoc;
8
9 /**
10  *
11  * User: Breto
12  * Date: 30/09/2005
13  * Time: 18:12:44
14  *
15  */

16 public class SharedDateFactory {
17
18
19   public SharedData newSharedDateFromStringSimpleValue(ReportDataType type, String JavaDoc simpleValue){
20     switch(type.getType()){
21       case ReportDataType.DATE_TYPE:
22       case ReportDataType.DATETIME_TYPE:
23         SimpleDateFormat JavaDoc format = new SimpleDateFormat JavaDoc("yyyyMMdd");
24         Date JavaDoc date = null;
25         try{
26           date = format.parse(simpleValue);
27         }catch (Exception JavaDoc e){
28           //ESTA EXCEPCION NO LA TENDRIA QUE LANZAR NUNCA. El objeto es escrito y levantado internamente
29
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 JavaDoc(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