Nathan,

Resurrecting this because I'm ready to commit.

On 10/29/2009 3:04 PM, Nathan Bubna wrote:
> On Thu, Oct 29, 2009 at 8:06 AM, Christopher Schultz
> <[email protected]> wrote:
>> Nathan,
>>
>> On 10/29/2009 11:02 AM, Christopher Schultz wrote:
>>> I like re-coding into SimpleDataFormat better.
>>
>> D'oh: that's not possible because DateFormat doesn't expose the pattern
>> it's using, so I'll have to return something unrelated. Hmm. I'm not a
>> big fan of NULL but it's also not exactly consistent with the API if an
>> error message is returned.
>>
>> Any ideas other than NULL?
> 
> Not really, because a) it's unlikely to ever occur in practice and b)
> that's the traditional VelocityTools response to bad inputs.  If you
> call $date.toLocalizedPattern($invalidInput) then that's little better
> than $date.noSuchMethod($validinput).  Either way, part of the
> reference is invalid, and we want to render it as an invalid
> reference.  Returning null accomplishes that.

While I agree that VelocityTools' traditional response to bad input is
null, the problem here isn't the user's bad input: instead, it's our
reliance on an unpublished but highly likely coincidence that DateFormat
always hands-out SimpleDateFormat objects.

For patterns other than "simple_date" and stuff like that, I could
simply construct a new SimpleDateFormat object and use that, but then
the behavior of toLocalizedPattern would differ from the other methods
-- that is, "short_date" would work, except when it doesn't :(

Thanks,
-chris

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to