KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > raptus > owxv3 > api > BusinessObject


1 /*
2  * eAdmin/OWX
3  * Copyright (C) 1996-2003 OWX-Project Team <owx-team@gmx.net>
4  */

5
6 package com.raptus.owxv3.api;
7
8 import java.text.*;
9 import java.util.Locale JavaDoc;
10
11 import com.raptus.owxv3.*;
12
13 /**
14  *
15  * <hr>
16  * <table width="100%" border="0">
17  * <tr>
18  * <td width="24%"><b>Filename</b></td><td width="76%">BusinessObject.java</td>
19  * </tr>
20  * <tr>
21  * <td width="24%"><b>Author</b></td><td width="76%">Guy Zürcher (gzuercher@raptus.com)</td>
22  * </tr>
23  * <tr>
24  * <td width="24%"><b>Date</b></td><td width="76%">15th of April 2001</td>
25  * </tr>
26  * </table>
27  * <hr>
28  * <table width="100%" border="0">
29  * <tr>
30  * <td width="24%"><b>Date / Author</b></td><td width="76%"><b>Changes</b></td>
31  * </tr>
32  * </table>
33  * <hr>
34  */

35 public class BusinessObject extends Object JavaDoc
36 {
37     /**
38      *
39      */

40     protected VModule vmodule = null;
41
42     /**
43      *
44      */

45     protected Locale JavaDoc locale = null;
46
47     /**
48      *
49      */

50     protected BusinessObject()
51     {
52     }
53
54     /**
55      *
56      */

57     public BusinessObject(VModule vm, Locale JavaDoc lcle)
58     {
59         this.vmodule = vm;
60         this.locale = lcle;
61     }
62
63     /**
64      *
65      */

66     public String JavaDoc getLocaleFormattedDate(java.util.Date JavaDoc dte)
67     {
68         if(dte == null)
69             return null;
70
71         DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, locale);
72         return df.format(dte);
73     }
74
75     /**
76      *
77      */

78     public String JavaDoc getLocaleFormattedTime(java.util.Date JavaDoc time)
79     {
80         if(time == null)
81             return null;
82
83         DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT, locale);
84         return df.format(time);
85     }
86
87     /**
88      *
89      */

90     public java.util.Date JavaDoc getDateFromStrings(String JavaDoc dateValue, String JavaDoc timeValue)
91     {
92         java.util.Date JavaDoc dval = null;
93
94         if(dateValue != null && dateValue.length() > 0)
95         {
96             if(timeValue == null)
97                 timeValue = getLocaleFormattedTime(new java.util.Date JavaDoc());
98
99             String JavaDoc dt = dateValue + " " + timeValue;
100             DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT,
101                                                            DateFormat.SHORT, locale);
102             try
103             {
104                 dval = df.parse(dt);
105             }
106             catch(ParseException e) {
107                 LoggingManager.log("ParseException while trying to convert. " + e.getMessage(), this);
108                 return dval;
109             }
110         }
111
112         return dval;
113     }
114     
115     /**
116      *
117      */

118     public static boolean isEmpty(String JavaDoc str)
119     {
120         return (str != null && str.length() > 0);
121     }
122 }
123
124 /* end class BusinessObject */
125
Popular Tags