01: package com.calipso.reportgenerator.userinterface;
02:
03: import com.calipso.reportgenerator.reportcalculator.SharedDate;
04: import com.calipso.reportgenerator.common.LanguageTraslator;
05: import com.calipso.reportgenerator.common.InfoException;
06: import com.calipso.common.DateEx;
07:
08: import javax.swing.*;
09: import javax.swing.text.Document;
10: import java.util.Date;
11: import java.util.GregorianCalendar;
12: import java.text.DateFormat;
13: import java.text.ParseException;
14: import java.text.SimpleDateFormat;
15:
16: /**
17: *
18: * User: soliveri
19: * Date: Dec 10, 2003
20: * Time: 1:16:50 PM
21: *
22: */
23:
24: public class DateTextField extends UserParameterTextField {
25:
26: public DateTextField() {
27: }
28:
29: public DateTextField(String text) {
30: super (text);
31: }
32:
33: public DateTextField(int columns) {
34: super (columns);
35: }
36:
37: public DateTextField(String text, int columns) {
38: super (text, columns);
39: }
40:
41: public DateTextField(Document doc, String text, int columns) {
42: super (doc, text, columns);
43: }
44:
45: public Object getFieldText() throws InfoException {
46: Date returnVal = null;
47: try {
48: String text = super .getText();
49: if (!text.equals("")) {
50: DateFormat dateFormat = SimpleDateFormat
51: .getDateInstance(DateFormat.SHORT,
52: LanguageTraslator.getLocale());
53: Date date = dateFormat.parse(text);
54: returnVal = date;
55: }
56: } catch (ParseException e) {
57: throw new InfoException(LanguageTraslator.traslate("483"),
58: e);
59: }
60: return returnVal;
61: }
62: }
|