aspose file tools*
The moose likes Java in General and the fly likes Extends java.text.Format Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Extends java.text.Format" Watch "Extends java.text.Format" New topic
Author

Extends java.text.Format

Josee Paradis
Greenhorn

Joined: Jan 12, 2004
Posts: 2
Hi,

I try to define a format for an object (an object I have created). I know I have to implement these 3 methods
1) format(Object obj, StringBuffer toAppendTo, FieldPosition pos)
2) formatToCharacterIterator(Object obj)
3) parseObject(String source, ParsePosition pos).

My problem is I don't know what to put in these methods.

For exemple my object has 3 fields. Two of them are string. I would like when format is call on this object display the two String.

Thank you
Rovas Kram
Ranch Hand

Joined: Aug 08, 2003
Posts: 135
I would start by reading the documentation for interface you're implementing or the abstract class that you're extending. What do these methods belong to?
Rovas Kram
Ranch Hand

Joined: Aug 08, 2003
Posts: 135
1) format(Object obj, StringBuffer toAppendTo, FieldPosition pos)
obj - your object with the two String objects.

toAppendTo - a StringBuffer that you instantiate(could be empty to begin with)

pos - new FieldPosition(0); object for storing the beginning and ending of a substring within your formatted String.

2) formatToCharacterIterator(Object obj)
The method is concrete(not abstract) and DateFormat does not override it so I don't know why you should.

3) parseObject(String source, ParsePosition pos).
source - the formatted String that you created from your object with the two Strings.

pos - the beginning and ending of a substring within your formatted String that you want to parse.

NOTE: May I suggests that you read the javadoc for java.text.DateFormat for and example.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Extends java.text.Format