ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/conient/uk/org/iscream/cms/conient/datacomponents/DateDataComponent.java
Revision: 1.2
Committed: Mon Jan 22 12:32:14 2001 UTC (23 years, 4 months ago) by ajm
Branch: MAIN
Changes since 1.1: +54 -1 lines
Log Message:
All tidy now, fully javadoc comments

File Contents

# User Rev Content
1 ajm 1.2 //---PACKAGE DECLARATION---
2    
3     //---IMPORTS---
4 ajm 1.1 import javax.swing.JLabel;
5     import java.awt.GridLayout;
6     import java.util.Date;
7     import java.text.DateFormat;
8    
9 ajm 1.2 /**
10     * This is DataComponent specifically for converting
11     * time since epoc dates into a nice format.
12     *
13     * As this is essentially just string data we just
14     * extend StringDataComponent, intercepting the value
15     * to convert it.
16     *
17     * It uses the JProgressBar to display the value.
18     *
19     * @author $Author: ajm4 $
20     * @version $Id: CPUDataComponent.java,v 1.1 2001/01/22 03:03:39 ajm4 Exp $
21     */
22 ajm 1.1 public class DateDataComponent extends StringDataComponent {
23 ajm 1.2
24     //---FINAL ATTRIBUTES---
25    
26     //---STATIC METHODS---
27    
28     //---CONSTRUCTORS---
29    
30     /**
31     * Creates the component with a friendly name to be
32     * used as label, but as we're a very basic
33     * extension of StringDataComponent, we just construct
34     * that.
35     *
36     * @param name the friendly name
37     */
38 ajm 1.1 public DateDataComponent(String name) {
39     super(name);
40     }
41 ajm 1.2
42     //---PUBLIC METHODS---
43    
44     //---PRIVATE METHODS---
45    
46     //---ACCESSOR/MUTATOR METHODS---
47    
48     /**
49     * This takes the String value of the parameter that this component
50     * is monitoring direct from the packet, it then performs all
51     * approriate conversions and displays the data.
52     *
53     * In this case all we do is change string and pass it to our
54     * super class for displaying.
55     *
56     * @param value the value for this data component
57     * @throws DataFormatException if there was a problem converting the data for display
58     */
59 ajm 1.1 public void setValue(String value) throws DataFormatException {
60     try {
61     value = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM).format(new Date(Long.parseLong(value)));
62     super.setValue(value);
63     } catch (Exception e) {
64     throw new DataFormatException("invalid data type for component");
65     }
66     }
67 ajm 1.2
68     //---ATTRIBUTES---
69    
70     //---STATIC ATTRIBUTES---
71    
72 ajm 1.1 }