com.ds.fw.types.data
Class FwTime

java.lang.Object
  |
  +--com.ds.fw.types.FwSimpleObject
        |
        +--com.ds.fw.types.data.FwTime
All Implemented Interfaces:
java.lang.Cloneable, FwCopyableIF, FwDisplayableIF, FwSimpleObjectIF, FwTimeIF, java.io.Serializable

public class FwTime
extends FwSimpleObject
implements FwTimeIF

See Also:
Serialized Form

Field Summary
 int _hour
           
 int _millisecond
           
 int _minute
           
 int _second
           
 
Constructor Summary
FwTime()
          Create a new Date with the default date of Jan 1st, FIRST YEAR.
 
Method Summary
 boolean addHour()
          Adds an hour to the time
 int addHours(int n)
          Adds(substracts) hours
 boolean addMillisecond()
          Adds a millisecond to the time
 int addMilliseconds(int n)
          Adds(substracts) milliseconds to the time
 boolean addMinute()
          Adds a minute to the time
 int addMinutes(int n)
          Adds(substracts) minutes
 boolean addSecond()
          Adds a second to the time
 int addSeconds(int n)
          Adds(substracts) seconds
 void beNow()
          Sets the date to be the current date
static com.ds.fw.types.data.FwTimeIF createNow()
          Create a new date with the current time.
static com.ds.fw.types.data.FwTimeIF createTime(java.lang.String s)
          Create a time from a string in the format "hh:mm:ss".
 boolean equals(java.lang.Object o)
          Compares if this FwTime object is equal to the object given as parameter
 boolean fromString(java.lang.String s)
          Set the time by parsing a string in the format hh:mm:ss.
 int getHour()
          Gets the hour
 java.util.Date getJavaDate()
          Gets the date
 java.util.Date getJavaDateWithoutMilliseconds()
          Gets the date without milliseconds
 int getMillisecond()
          Gets the milliseconds
 int getMinute()
          Gets the minutes
static com.ds.fw.types.data.FwTimeIF getNow()
          Create a new date with the current time.
 int getSecond()
          Gets the seconds
 com.ds.fw.types.data.FwTimeIF getTimeCopy()
           
 int hashCode()
          Generate a hash code for this object
 boolean isAfter(com.ds.fw.types.data.FwTimeIF t)
          Verify if the time represented by this FwTime object is after this given as parameter
 boolean isBefore(com.ds.fw.types.data.FwTimeIF t)
          Verify if the time represented by this FwTime object is before this given as parameter
 void setHour(int o)
          Sets the hour
 void setJavaDate(java.util.Date d)
          Sets the date with new one
 void setMillisecond(int o)
          Sets the milliseconds
 void setMinute(int o)
          Sets the minutes
 void setSecond(int o)
          Sets the seconds
 boolean subtractHour()
          Substracts an hour
 boolean subtractMillisecond()
          Substracts a millisecond
 boolean subtractMinute()
          Substracts a minute
 boolean subtractSecond()
          Substracts a second
 java.lang.String toStringValue()
          Returns the string representation of the time with format "hs:ms:ss"
 
Methods inherited from class com.ds.fw.types.FwSimpleObject
getClassName, getClone, getCopy, getCopy, getDeepCopy, getDisplayString, getDisplayStringFor, postCopy, printStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.ds.fw.types.FwSimpleObjectIF
getClassName, getClone, getCopy, getCopy, getDeepCopy, getDisplayString, getDisplayStringFor, postCopy, toString
 

Field Detail

_hour

public int _hour

_minute

public int _minute

_second

public int _second

_millisecond

public int _millisecond
Constructor Detail

FwTime

public FwTime()
Create a new Date with the default date of Jan 1st, FIRST YEAR.

Method Detail

getNow

public static com.ds.fw.types.data.FwTimeIF getNow()
Create a new date with the current time.


createNow

public static com.ds.fw.types.data.FwTimeIF createNow()
Create a new date with the current time.


createTime

public static com.ds.fw.types.data.FwTimeIF createTime(java.lang.String s)
Create a time from a string in the format "hh:mm:ss".


getHour

public int getHour()
Gets the hour

Specified by:
getHour in interface FwTimeIF
Returns:
the hour as int

setHour

public void setHour(int o)
Sets the hour

Specified by:
setHour in interface FwTimeIF
Parameters:
o - - the new value

getMinute

public int getMinute()
Gets the minutes

Specified by:
getMinute in interface FwTimeIF
Returns:
the minutes

setMinute

public void setMinute(int o)
Sets the minutes

Specified by:
setMinute in interface FwTimeIF
Parameters:
o - - the new value for the minutes

getSecond

public int getSecond()
Gets the seconds

Specified by:
getSecond in interface FwTimeIF
Returns:
the value for the seconds

setSecond

public void setSecond(int o)
Sets the seconds

Specified by:
setSecond in interface FwTimeIF
Parameters:
o - - the new value for the seconds

getMillisecond

public int getMillisecond()
Gets the milliseconds

Specified by:
getMillisecond in interface FwTimeIF
Returns:
the current value for the milliseconds

setMillisecond

public void setMillisecond(int o)
Sets the milliseconds

Specified by:
setMillisecond in interface FwTimeIF
Parameters:
o - - the new value for the milliseconds

beNow

public void beNow()
Sets the date to be the current date

Specified by:
beNow in interface FwTimeIF

getJavaDate

public java.util.Date getJavaDate()
Gets the date

Specified by:
getJavaDate in interface FwTimeIF
Returns:
the date as java.util.Date object

getJavaDateWithoutMilliseconds

public java.util.Date getJavaDateWithoutMilliseconds()
Gets the date without milliseconds

Specified by:
getJavaDateWithoutMilliseconds in interface FwTimeIF
Returns:
the date

setJavaDate

public void setJavaDate(java.util.Date d)
Sets the date with new one

Specified by:
setJavaDate in interface FwTimeIF
Parameters:
d - - the new date

equals

public boolean equals(java.lang.Object o)
Compares if this FwTime object is equal to the object given as parameter

Overrides:
equals in class java.lang.Object
Parameters:
o - - the object to be compared for equality with this FwTime object
Returns:
true if they are equals , false - otherwise

hashCode

public int hashCode()
Generate a hash code for this object

Overrides:
hashCode in class java.lang.Object
Returns:
an int containing the hashcode

isBefore

public boolean isBefore(com.ds.fw.types.data.FwTimeIF t)
Verify if the time represented by this FwTime object is before this given as parameter

Specified by:
isBefore in interface FwTimeIF
Parameters:
t -
Returns:
true if it is before, false - otherwise

isAfter

public boolean isAfter(com.ds.fw.types.data.FwTimeIF t)
Verify if the time represented by this FwTime object is after this given as parameter

Specified by:
isAfter in interface FwTimeIF
Parameters:
t -
Returns:
true if it is after, false - otherwise

toStringValue

public java.lang.String toStringValue()
Returns the string representation of the time with format "hs:ms:ss"

Specified by:
toStringValue in interface FwSimpleObjectIF
Overrides:
toStringValue in class FwSimpleObject
Returns:
the string representation of the time

fromString

public boolean fromString(java.lang.String s)
Set the time by parsing a string in the format hh:mm:ss. The hour, minute and seconds may be 1 or two digits.

Specified by:
fromString in interface FwTimeIF

addMillisecond

public boolean addMillisecond()
Adds a millisecond to the time

Specified by:
addMillisecond in interface FwTimeIF
Returns:
false if the current value of the millisecond is less than 1000 after the incrementation

addSecond

public boolean addSecond()
Adds a second to the time

Specified by:
addSecond in interface FwTimeIF
Returns:
false if the seconds are less than 60 after the incrementation

addMinute

public boolean addMinute()
Adds a minute to the time

Specified by:
addMinute in interface FwTimeIF
Returns:
false if the minutes are less than 60 after the incrementation

addHour

public boolean addHour()
Adds an hour to the time

Specified by:
addHour in interface FwTimeIF
Returns:
false if the hours are less than 24 after the incrementation

subtractMillisecond

public boolean subtractMillisecond()
Substracts a millisecond

Specified by:
subtractMillisecond in interface FwTimeIF
Returns:
false if the milliseconds are greater than -1 after the substraction

subtractSecond

public boolean subtractSecond()
Substracts a second

Specified by:
subtractSecond in interface FwTimeIF
Returns:
false if the seconds are less than -1 after the substraction

subtractMinute

public boolean subtractMinute()
Substracts a minute

Specified by:
subtractMinute in interface FwTimeIF
Returns:
false if the minutes are less than -1 after the substraction

subtractHour

public boolean subtractHour()
Substracts an hour

Specified by:
subtractHour in interface FwTimeIF
Returns:
false if the hours are greater than -1 after the substraction

addMilliseconds

public int addMilliseconds(int n)
Adds(substracts) milliseconds to the time

Specified by:
addMilliseconds in interface FwTimeIF
Parameters:
n - - the number of milliseconds to be added(or substracted if n<0)
Returns:
the days to be added or substracted after the incrementation(substraction) of the milliseconds

addSeconds

public int addSeconds(int n)
Adds(substracts) seconds

Specified by:
addSeconds in interface FwTimeIF
Parameters:
n - - the number of the seconds to be added (or substracted if n<0)
Returns:
the days to be added or substracted after the incrementation(substraction) of the seconds if there is any

addMinutes

public int addMinutes(int n)
Adds(substracts) minutes

Specified by:
addMinutes in interface FwTimeIF
Parameters:
n - - the number of the minutes to be added( or substracted if n < 0)
Returns:
the days to be added or substracted after the incrementation(substraction) of the seconds if there is any

addHours

public int addHours(int n)
Adds(substracts) hours

Specified by:
addHours in interface FwTimeIF
Parameters:
n - - the number of hours to be added(substracted if n < 0)
Returns:
the number of the days to be added(substracted) after the incrementation(substraction)

getTimeCopy

public com.ds.fw.types.data.FwTimeIF getTimeCopy()
Specified by:
getTimeCopy in interface FwTimeIF