1 package com.calipso.reportgenerator.userinterface; 2 3 import com.calipso.reportgenerator.common.LanguageTraslator; 4 5 import javax.swing.text.Document ; 6 import java.util.Date ; 7 import java.text.DateFormat ; 8 import java.text.SimpleDateFormat ; 9 import java.text.ParseException ; 10 11 16 17 public class UPDateTextField extends UPTextField { 18 19 public UPDateTextField() { 20 } 21 22 public UPDateTextField(String text) { 23 super(text); 24 } 25 26 public UPDateTextField(int columns) { 27 super(columns); 28 } 29 30 public UPDateTextField(String text, int columns) { 31 super(text, columns); 32 } 33 34 public UPDateTextField(Document doc, String text, int columns) { 35 super(doc, text, columns); 36 } 37 38 public boolean isLessThan(UPTextField upTextField) { 39 Date date = (Date ) getComponentValue(); 40 int result = date.compareTo((Date )upTextField.getComponentValue()); 41 if(result > 0) { 42 return false; 43 } else { 44 return true; 45 } 46 } 47 48 public Object getComponentValue() { 49 Date returnVal = null; 50 try { 51 String text = super.getText(); 52 if(!text.equals("")) { 53 DateFormat dateFormat = SimpleDateFormat.getDateInstance(DateFormat.SHORT, LanguageTraslator.getLocale()); 54 Date date = dateFormat.parse(text); 55 returnVal = date; 56 } 57 } catch(ParseException e) { 58 e.printStackTrace(); 59 } 60 return returnVal; 61 } 62 } 63 | Popular Tags |