01: //The contents of this file are subject to the Mozilla Public License Version 1.1
02: //(the "License"); you may not use this file except in compliance with the
03: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
04: //
05: //Software distributed under the License is distributed on an "AS IS" basis,
06: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
07: //for the specific language governing rights and
08: //limitations under the License.
09: //
10: //The Original Code is "The Columba Project"
11: //
12: //The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
13: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
14: //
15: //All Rights Reserved.
16:
17: package org.columba.core.versioninfo;
18:
19: import java.lang.reflect.Method;
20: import java.util.Calendar;
21: import java.util.Date;
22:
23: public class VersionInfo {
24:
25: // Use static variables so the date is only updated once
26: // during runtime
27: private static Date TODAY = new Date();
28:
29: private static String YEAR = Integer.toString(Calendar
30: .getInstance().get(Calendar.YEAR));
31: private static String MONTH = Integer.toString(Calendar
32: .getInstance().get(Calendar.MONTH) + 1);
33: private static String DAY = Integer.toString(Calendar.getInstance()
34: .get(Calendar.DAY_OF_MONTH));
35:
36: private static String DATE = YEAR
37: + (MONTH.length() == 1 ? "0" : "") + MONTH
38: + (DAY.length() == 1 ? "0" : "") + DAY;
39:
40: public static String getVersion() {
41: try {
42: Method getVersionMethod = Class.forName(
43: "org.columba.core.versioninfo.ColumbaVersionInfo")
44: .getMethod("getVersion", new Class[0]);
45:
46: return (String) getVersionMethod
47: .invoke(null, new Object[0]);
48: } catch (Exception e) {
49: return "CVS-" + DATE;
50: }
51:
52: }
53:
54: public static Date getBuildDate() {
55: try {
56: Method getBuildDateMethod = Class.forName(
57: "org.columba.core.versioninfo.ColumbaVersionInfo")
58: .getMethod("getBuildDate", new Class[0]);
59:
60: return (Date) getBuildDateMethod
61: .invoke(null, new Object[0]);
62: } catch (Exception e) {
63: return TODAY;
64: }
65:
66: }
67:
68: }
|