# Class PartialTimestampFormat

java.lang.Object
java.text.Format
org.ggf.drmaa.PartialTimestampFormat

All Implemented Interfaces:
  `Serializable, Cloneable`

public class PartialTimestampFormat extends 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 if `CENTURY` is set, `YEAR`, `MONTH`, and `DAY_OF_MONTH` must also be set. `SECONDS` and `ZONE_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

## Nested Class Summary

### Nested classes/interfaces inherited from class Format

`Format.Field`

## Constructor Summary

Constructors
Constructor
Description
`PartialTimestampFormat()`
Creates a new instance of PartialTimestampFormat

## Method Summary

Modifier and Type
Method
Description
`Object`
`clone()`
Creates a copy of this object.
`StringBuffer`
`format(Object obj, StringBuffer stringBuffer, FieldPosition fieldPosition)`
Translates the PartialTimestamp into a DRMAA specified time string and appends the string to the given StringBuffer.
`String`
`format(PartialTimestamp obj)`
Translates the PartialTimestamp into a DRMAA specified time string.
`StringBuffer`
`format(PartialTimestamp obj, StringBuffer stringBuffer, FieldPosition fieldPosition)`
Translates the PartialTimestamp into a DRMAA specified time string and appends the string to the given StringBuffer.
`PartialTimestamp`
`parse(String str)`
Translates a DRMAA specified time string into a PartialTimestamp object.
`PartialTimestamp`
`parse(String str, ParsePosition parsePosition)`
Translates a DRMAA specified time string into a PartialTimestamp object.
`Object`
`parseObject(String str, ParsePosition parsePosition)`
Translates a DRMAA specified time string into a PartialTimestamp object.

### Methods inherited from class Format

`format, formatToCharacterIterator, parseObject`

### Methods inherited from class Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### PartialTimestampFormat

public PartialTimestampFormat()
Creates a new instance of PartialTimestampFormat

## Method Details

### clone

public Object clone()
Creates a copy of this object.

Overrides:
  `clone` in class `Format`
Returns:
  a copy of this object

### format

public StringBuffer format(Object obj, StringBuffer stringBuffer, 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 to `stringBuffer.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`, and `DAY_OF_MONTH` must also be set. `SECONDS` and `ZONE_OFFSET` are always optional.

Specified by:
  `format` in class `Format`
Parameters:
  `obj` - the object to format
  `stringBuffer` - the StringBuffer to which to append the results
  `fieldPosition` - ignored
Returns:
  the stringBuffer parameter

### format

public StringBuffer format(PartialTimestamp obj, StringBuffer stringBuffer, 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 to `stringBuffer.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`, and `DAY_OF_MONTH` must also be set. `SECONDS` and `ZONE_OFFSET` are always optional.

Parameters:
  `obj` - the object to format
  `stringBuffer` - the StringBuffer to which to append the results
  `fieldPosition` - ignored
Returns:
  the stringBuffer parameter

### format

public String format(PartialTimestamp obj)
Translates the PartialTimestamp into a DRMAA specified time string. This method is equivalent to `format(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`, and `DAY_OF_MONTH` must also be set. `SECONDS` and `ZONE_OFFSET` are always optional.

Parameters:
  `obj` - the object to format
Returns:
  the DRMAA specified time string

### parse

public PartialTimestamp parse(String str) throws ParseException
Translates a DRMAA specified time string into a PartialTimestamp object. This method will parse as far as possible, but after successfully parsing the `HOUR_OF_DAY` and `MINUTE` 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:
  `ParseException` - thrown if the string is not parsable.

### parse

public PartialTimestamp parse(String str, 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 string
  `parsePosition` - the parse position object
Returns:
  a PartialTimestamp object

### parseObject

public Object parseObject(String str, 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 class `Format`
Parameters:
  `str` - a DRMAA specified time string
  `parsePosition` - the parse position object
Returns:
  a PartialTimestamp object