/** * SFTimeUtility. *
* This class translate times from Java Time to SFTime and vice versa. T *
* Freeware, no liabilities assumed or implied. *
* Not for use in mission critical environment. *
* Copyright Finlayson Consulting 1997. All rights reserved. * @version 0.4 * @author Ross A. Finlayson * @author FC VRML Group */ import vrml.*; import vrml.field.*; import vrml.node.*; // SFTime Utility public class SFTimeUtility extends Object { /** * This method returns the current system time as a new ConstSFTime. * @return ConstSFTime constsftimenow */ public static final ConstSFTime getConstSFTimeNow() { long timenow=System.currentTimeMillis(); double sftimenow = (double)(timenow/1000); ConstSFTime sftime=new ConstSFTime(sftimenow); return sftime; } /** * This method returns the current system time as a new SFTime. * @return SFTime sftimenow */ public static final SFTime getSFTimeNow() { long timenow=System.currentTimeMillis(); double sftimenow = (double)(timenow/1000); SFTime sftime=new SFTime(sftimenow); return sftime; } /** * This method returns the current system time as a new double. * @return double sftimenow */ public static final double getDoubleTimeNow() { long timenow=System.currentTimeMillis(); double sftimenow = (double)(timenow/1000); return sftimenow; } /** * This method returns from the time in milliseconds as a new ConstSFTime. * @param time time in milliseconds to set * @return ConstSFTime constsftime */ public static final ConstSFTime getConstSFTime(long time) { double sftimenow=(double)(time/1000); ConstSFTime sftime=new ConstSFTime(sftimenow); return sftime; } /** * This method returns from the time in milliseconds as a new SFTime. * @param time time in milliseconds to set * @return SFTime sftime */ public static final SFTime getSFTime(long time) { double sftimenow=(double)(time/1000); SFTime sftime=new SFTime(sftimenow); return sftime; } /** * This method returns from the time in milliseconds as a new double. * @param time time in milliseconds to set * @return double sftimevalue */ public static final double getDoubleTime(long time) { double sftime=(double)(time/1000); return sftime; } /** * This method returns from SFTime object as a new long. * @param sftime SFTime object to set * @return timemillis Time value of argument in milliseconds */ public static final long getTimeMillis(SFTime sftime) { double sftimevalue=(double)sftime.getValue(); long timemillis= (long)(sftimevalue*1000); return timemillis; } /** * This method returns from ConstSFTime object as a new long. * @param sftime ConstSFTime object to set * @return timemillis Time value of argument in milliseconds */ public static final long getTimeMillis(ConstSFTime sftime) { double sftimevalue=(double)sftime.getValue(); long timemillis= (long)(sftimevalue*1000); return timemillis; } /** * This method returns from double SFTime value as a new long. * @param sftime double SFTime value to set * @return timemillis Time value of argument in milliseconds */ public static final long getTimeMillis(double sftime) { long timemillis= (long)(sftime*1000); return timemillis; } }