[threeten-dev] javax.time.format.DateTimeFormattter#toFormat(Class<?> parseType) API specification
yoshito_umaoka at us.ibm.com
yoshito_umaoka at us.ibm.com
Tue Dec 4 20:02:29 PST 2012
Hi all,
I have some comments and questions about public Format
DateTimeFormatter#toFormat(Class<?> parseType) API specification [
http://threeten.sourceforge.net/apidocs-2012-10-25/javax/time/format/DateTimeFormatter.html#toFormat%28java.lang.Class%29
].
The specification says:
"Returns this formatter as a java.text.Format instance that will parse to
the specified type."
I think the implementation is likely supporting only some known object
types and the method would throw IllegalArgumentException or something if
the given parseType is not supported. I think the spec should clarify what
kind of argument is likely supported here and type of exception (or
returning null?) when unsupported type is specified.
Also, it says:
"The format will throw IndexOutOfBoundsException in line with those thrown
by the print and parse methods."
This description does not sound right. My understanding is "The format" is
an instance of java.text.Format subclass. Format defines two parse methods
- 1) Object parseObject(String) and 2) abstract Object parseObject(String,
ParsePosition) - I do not know what "print" method in the spec actually
means (Format defines "format" methods, not "print"). In addition to
these, it's difficult to understand why IndexOutOfBoundsException might be
thrown by "The format". By the contract of java.textFormat, format method
should not throw any exception and parseObject should throw
java.text.ParseException on parse failure. So I have no idea where this
IndexOutOfBoundsException come from.
Thanks,
Yoshito Umaoka (ICU Project at IBM)
More information about the threeten-dev
mailing list