Main Page | Class Hierarchy | Class List | File List | Class Members | Related Pages

ISOtoRbnbTime.java

Go to the documentation of this file.
00001 
00009 package org.nees.daq;
00010 
00011 import java.util.*;
00012 
00014 public class ISOtoRbnbTime {
00015     private int year;
00016     private int month;
00017     private int day;
00018     private int hour;
00019     private int min;
00020     private int sec;
00021     private int frac;
00022     private double convertedTStamp;
00023     boolean     is_valid;
00024 
00025     /*
00026      @brief Constructor, converts input
00027      @param ISOString ISO timestamp
00028     */
00029     ISOtoRbnbTime(String ISOString)
00030     {
00031         is_valid = false;
00032         convert(ISOString);
00033     }
00034     
00040     private void convert(String ISOString) {
00041 
00042         StringTokenizer st = new StringTokenizer(ISOString, "-T:\t\n. ");
00043         try
00044         {
00045             year = Integer.parseInt(st.nextToken());
00046             month = Integer.parseInt(st.nextToken());
00047             day = Integer.parseInt(st.nextToken());
00048             hour = Integer.parseInt(st.nextToken());
00049             min = Integer.parseInt(st.nextToken());
00050             sec = Integer.parseInt(st.nextToken());
00051             frac = Integer.parseInt(st.nextToken());
00052             is_valid = true;
00053             //System.out.println("String " + ISOString + ", Parsed into " + year + "." + month + "." + day + "." + hour + "." + min + "." + sec + "." + frac);
00054             if (year > 1900) year -= 1900;
00055             month -= 1;
00056             //System.out.println("String " + ISOString + ", Parsed into " + year + "." + month + "." + day + "." + hour + "." + min + "." + sec + "." + frac);
00057             convertedTStamp = (double)(Date.UTC(year,month,day,hour,min,sec)/1000.0);
00058             convertedTStamp += (double)(frac/100000.0);
00059             //System.out.println("converted timestamp = " + convertedTStamp);
00060             //long milliseconds = (long) (convertedTStamp*1000.);
00061             //Date date = new Date(milliseconds);
00062             //java.text.SimpleDateFormat format = new 
00063             //      java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
00064             //System.out.println("Confirm Date/Time: " + format.format(date) + "\n");
00065         } catch (Exception ignore) {}
00066     }
00067     
00068     /*
00069      @brief Return pre-computed result
00070      @retval time RBNB-format timestamp
00071     */
00072     public double getValue() {
00073         return(convertedTStamp);
00074     }
00075 }
00076 

Generated on Tue Mar 23 11:54:24 2004 for Data turbine for NEESGrid by doxygen 1.3.6