![]() |
|||
DateValue.javaGo to the documentation of this file.00001 /* 00002 * Date.java 00003 * 00004 * Created on 19 mars 2003, 13:38 00005 * 00006 * Copyright (C) 2003 Philippe MOULIN 00007 * www.net2map.org 00008 * 00009 * This program is free software; you can redistribute it and/or 00010 * modify it under the terms of the GNU General Public License 00011 * as published by the Free Software Foundation; either version 2 00012 * of the License, or (at your option) any later version. 00013 * 00014 * This program is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 * GNU Lesser General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU General Public License 00020 * along with this program; if not, write to the Free Software 00021 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00022 */ 00023 package org.net2map.pov.dimension.date; 00024 00028 public class DateValue 00029 extends org.net2map.pov.dimension.Value 00030 { 00031 00032 private static org.apache.log4j.Logger logger = 00033 org.apache.log4j.Logger.getLogger(DateValue.class.getName()); 00035 private java.util.Calendar theDate; 00037 public DateValue() 00038 { 00039 logger.setLevel((org.apache.log4j.Level)org.apache.log4j.Priority.DEBUG); 00040 logger.warn("Creating..."); 00041 theDate = java.util.Calendar.getInstance (); 00042 theDate.setTimeInMillis ( (long)0 ); 00043 theDate.set (1970,1,1,0,0,0); 00044 logger.warn("...Created"); 00045 } 00046 00047 public DateValue(java.util.Date paramInitializer) 00048 { 00049 logger.setLevel((org.apache.log4j.Level)org.apache.log4j.Priority.DEBUG); 00050 logger.warn("Creating..."); 00051 theDate = java.util.Calendar.getInstance (); 00052 theDate.setTimeInMillis ( (long)0 ); 00053 theDate.setTime(paramInitializer); 00054 logger.warn("...Created"); 00055 } 00056 00061 public void setValue ( java.util.Calendar newValue ) 00062 { 00063 System.out.println( "Changing date from " + 00064 theDate.get ( java.util.Calendar.YEAR ) + 00065 "/" + 00066 theDate.get ( java.util.Calendar.MONTH ) + 00067 "/" + 00068 theDate.get ( java.util.Calendar.DATE ) + 00069 " to " + 00070 newValue.get( java.util.Calendar.YEAR ) + 00071 "/" + 00072 newValue.get ( java.util.Calendar.MONTH ) + 00073 "/" + 00074 newValue.get (java.util.Calendar.DATE ) ); 00075 00076 theDate.set ( newValue.get ( java.util.Calendar.YEAR ), 00077 newValue.get ( java.util.Calendar.MONTH ), 00078 newValue.get ( java.util.Calendar.DATE ), 00079 0, //hour 00080 0, //minute 00081 0 //second 00082 ); 00083 00084 } 00085 00086 public void setValue(java.util.Date newValue) 00087 { 00088 theDate.setTime(newValue); 00089 } 00090 public void setValue(String newValue) 00091 { 00092 theDate.setTimeInMillis(Long.parseLong(newValue)); 00093 } 00094 00099 public long toLong() 00100 { 00101 return ( theDate.getTimeInMillis () ); 00102 } 00103 00108 public String toString() 00109 { 00110 return ( "" + 00111 theDate.get ( java.util.Calendar.DATE ) + 00112 "/" + 00113 theDate.get ( java.util.Calendar.MONTH ) + 00114 "/" + 00115 theDate.get ( java.util.Calendar.YEAR )); 00116 } 00117 00118 public java.util.Date toDate() 00119 { 00120 return theDate.getTime(); 00121 } 00122 00123 public int compareTo(java.util.Date anotherDate) 00124 { 00125 return(toDate().compareTo(anotherDate)); 00126 } 00127 } |
|||
|
Accueil | Téléchargement | Manuel
| Doc. technique | Sources CVS |
Faq | Nous contacter
©2003 - All Rights Reserved |
|||