FileDocCategorySizeDatePackage
TimeField.javaAPI DocphoneME MR2 API (J2ME)5935Wed May 02 18:00:42 BST 2007gov.nist.javax.sdp.fields

TimeField

public class TimeField extends SDPField
Time Field.
version
JSR141-PUBLIC-REVIEW (subject to change). This code is in the public domain.

Fields Summary
protected long
startTime
Start time.
protected long
stopTime
Stop time.
Constructors Summary
public TimeField()
Default constructor.

	super(TIME_FIELD);
    
Methods Summary
public java.lang.Objectclone()
Copies the current instance.

return
the copy of this object

	TimeField retval = new TimeField();
	retval.startTime = this.startTime;
	retval.stopTime = this.stopTime;
	return retval;
    
public java.lang.Stringencode()
Gets the string encoded version of this object.

return
encoded string of object contents
since
v1.0

	return new StringBuffer()
	    .append(TIME_FIELD)
	    .append(startTime) 
	    .append(Separators.SP)
	    .append(stopTime)
	    .append(Separators.NEWLINE)
	    .toString();
    
public java.util.DategetStart()
Returns the start time of the conference/session.

throws
SdpParseException if a parsing error occurs
return
the date

	return new Date(startTime*1000 + SdpConstants.NTP_CONST);
    
public longgetStartTime()
Gets the start time.

return
start time

 
	return startTime; 
    
public java.util.DategetStop()
Returns the stop time of the session.

throws
SdpParseException if a parsing error occurs
return
the stop time of the session.

	return new Date(stopTime*1000 + SdpConstants.NTP_CONST);
    
public longgetStopTime()
Gets the stop time.

return
start stop time

 
	return stopTime; 
    
public booleangetTypedTime()
Returns whether the field will be output as a typed time or a integer value. Typed time is formatted as an integer followed by a unit character. The unit indicates an appropriate multiplier for the integer. The following unit types are allowed.
d - days (86400 seconds)
h - hours (3600 seconds)
m - minutes (60 seconds)
s - seconds ( 1 seconds)

return
true, if the field will be output as a typed time; false, if as an integer value.

	return false;
    
public booleanisZero()
Returns whether the start and stop times were set to zero (in NTP).

return
true if tsrat or stop time are zero

	long stopTime = getStopTime();
	long startTime = getStartTime();
	if (stopTime == 0 && startTime == 0)
	    return true;
	else return false;
    
public voidsetStart(java.util.Date start)
Sets the start time of the conference/session.

param
start the new start time for the session.
throws
SdpException if the date is null

	if (start == null)
	    throw new SdpException("The date is null");
	else {
	    this.startTime = start.getTime()/1000 - SdpConstants.NTP_CONST;
	}
    
public voidsetStartTime(long startTime)
Sets the start time member.

param
startTime tthe new start time

 
	this.startTime = startTime; 
    
public voidsetStop(java.util.Date stop)
Sets the stop time of the session.

param
stop the new stop time
throws
SdpException if the date is null

	if (stop == null)
	    throw new SdpException("The date is null");
	else {
	    this.stopTime = stop.getTime() / 1000 - SdpConstants.NTP_CONST;
	}
    
public voidsetStopTime(long stopTime)
Sets the stop time member.

param
stopTime the new stop mtime

 
	this.stopTime = stopTime; 
    
public voidsetTypedTime(boolean typedTime)
Sets whether the field will be output as a typed time or a integer value. Typed time is formatted as an integer followed by a unit character. The unit indicates an appropriate multiplier for the integer. The following unit types are allowed.
d - days (86400 seconds)
h - hours (3600 seconds)
m - minutes (60 seconds)
s - seconds ( 1 seconds)

param
typedTime if set true, the start and stop times will be output in an optimal typed time format; if false, the times will be output as integers.

 
    
public voidsetZero()
Sets the start and stop times to zero (in NTP).

	setStopTime(0);
	setStartTime(0);