Class PartialTimestampFormat
- java.lang.Object
-
- java.text.Format
-
- org.ggf.drmaa.PartialTimestampFormat
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
public class PartialTimestampFormat extends java.text.Format
This class coverts a PartialTimestamp to and from the DRMAA specified time string. In order to represent a PartialTimestamp object as a string, the PartialTimestamp object cannot have an unset field that is less significant than the most significant set field. That is to say that ifCENTURY
is set,YEAR
,MONTH
, andDAY_OF_MONTH
must also be set.SECONDS
andZONE_OFFSET
are always optional.Example:
PartialTimestamp date = new PartialTimestamp(); PartialTimestampFormat ptf = new PartialTimestampFormat(); date.set(PartialTimestamp.HOUR_OF_DAY, 11); date.set(PartialTimestamp.MINUTE, 30); String timeString = ptf.format(date); PartialTimestamp date2 = ptf.parse(timeString); assert(date.equals(date2));
- Since:
- 0.5
- Version:
- 1.0
- See Also:
PartialTimestamp
, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description PartialTimestampFormat()
Creates a new instance of PartialTimestampFormat
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
clone()
Creates a copy of this object.java.lang.StringBuffer
format(java.lang.Object obj, java.lang.StringBuffer stringBuffer, java.text.FieldPosition fieldPosition)
Translates the PartialTimestamp into a DRMAA specified time string and appends the string to the given StringBuffer.java.lang.String
format(PartialTimestamp obj)
Translates the PartialTimestamp into a DRMAA specified time string.java.lang.StringBuffer
format(PartialTimestamp obj, java.lang.StringBuffer stringBuffer, java.text.FieldPosition fieldPosition)
Translates the PartialTimestamp into a DRMAA specified time string and appends the string to the given StringBuffer.PartialTimestamp
parse(java.lang.String str)
Translates a DRMAA specified time string into a PartialTimestamp object.PartialTimestamp
parse(java.lang.String str, java.text.ParsePosition parsePosition)
Translates a DRMAA specified time string into a PartialTimestamp object.java.lang.Object
parseObject(java.lang.String str, java.text.ParsePosition parsePosition)
Translates a DRMAA specified time string into a PartialTimestamp object.
-
-
-
Method Detail
-
clone
public java.lang.Object clone()
Creates a copy of this object.- Overrides:
clone
in classjava.text.Format
- Returns:
- a copy of this object
-
format
public java.lang.StringBuffer format(java.lang.Object obj, java.lang.StringBuffer stringBuffer, java.text.FieldPosition fieldPosition)
Translates the PartialTimestamp into a DRMAA specified time string and appends the string to the given StringBuffer. Since the PartialTimestampFormat class doesn't use fields, the fieldPosition parameter is ignored. This method is equivalent tostringBuffer.append (format (obj))
.In order to represent a PartialTimestamp object as a string, the PartialTimestamp object cannot have an unset field that is less significant than the most significant set field. TThat is to say that if
CENTURY
is set,YEAR
,MONTH
, andDAY_OF_MONTH
must also be set.SECONDS
andZONE_OFFSET
are always optional.- Specified by:
format
in classjava.text.Format
- Parameters:
obj
- the object to formatstringBuffer
- the StringBuffer to which to append the resultsfieldPosition
- ignored- Returns:
- the stringBuffer parameter
-
format
public java.lang.StringBuffer format(PartialTimestamp obj, java.lang.StringBuffer stringBuffer, java.text.FieldPosition fieldPosition)
Translates the PartialTimestamp into a DRMAA specified time string and appends the string to the given StringBuffer. Since the PartialTimestampFormat class doesn't use fields, the fieldPosition parameter is ignored. This method is equivalent tostringBuffer.append (format (obj))
.In order to represent a PartialTimestamp object as a string, the PartialTimestamp object cannot have an unset field that is less significant than the most significant set field. TThat is to say that if
CENTURY
is set,YEAR
,MONTH
, andDAY_OF_MONTH
must also be set.SECONDS
andZONE_OFFSET
are always optional.- Parameters:
obj
- the object to formatstringBuffer
- the StringBuffer to which to append the resultsfieldPosition
- ignored- Returns:
- the stringBuffer parameter
-
format
public java.lang.String format(PartialTimestamp obj)
Translates the PartialTimestamp into a DRMAA specified time string. This method is equivalent toformat(obj, new StringBuffer (), new FieldPosition(0)).toString()
.In order to represent a PartialTimestamp object as a string, the PartialTimestamp object cannot have an unset field that is less significant than the most significant set field. TThat is to say that if
CENTURY
is set,YEAR
,MONTH
, andDAY_OF_MONTH
must also be set.SECONDS
andZONE_OFFSET
are always optional.- Parameters:
obj
- the object to format- Returns:
- the DRMAA specified time string
-
parse
public PartialTimestamp parse(java.lang.String str) throws java.text.ParseException
Translates a DRMAA specified time string into a PartialTimestamp object. This method will parse as far as possible, but after successfully parsing theHOUR_OF_DAY
andMINUTE
fields, if it encounters unparsable text, it will stop and will not throw a java.text.ParseException.- Parameters:
str
- a DRMAA specified time string- Returns:
- a PartialTimestamp object
- Throws:
java.text.ParseException
- thrown if the string is not parsable.
-
parse
public PartialTimestamp parse(java.lang.String str, java.text.ParsePosition parsePosition)
Translates a DRMAA specified time string into a PartialTimestamp object. This method will parse as far as possible. Upon completion, the parse position object will contain the index of the last character parsed.- Parameters:
str
- a DRMAA specified time stringparsePosition
- the parse position object- Returns:
- a PartialTimestamp object
-
parseObject
public java.lang.Object parseObject(java.lang.String str, java.text.ParsePosition parsePosition)
Translates a DRMAA specified time string into a PartialTimestamp object. This method will parse as far as possible. Upon completion, the parse position object will contain the index of the last character parsed.- Specified by:
parseObject
in classjava.text.Format
- Parameters:
str
- a DRMAA specified time stringparsePosition
- the parse position object- Returns:
- a PartialTimestamp object
-
-