JodaTime DateFormatter to display milliseconds if nonzero
Posted
by Mike
on Stack Overflow
See other posts from Stack Overflow
or by Mike
Published on 2010-05-10T22:19:34Z
Indexed on
2010/05/10
22:24 UTC
Read the original article
Hit count: 625
I want to display a list of dates that may or may not have milliseconds on them. If a certain entry has milliseconds, then it should be displayed like yyyy MM dd HH:mm:ss.SSS
. If it doesn't have the millis, I need it displayed as yyyy MM dd HH:mm:ss
.
I suppose the general question is: Is there a way to describe an optional format string parameter?
(I'd like to avoid refactoring all of the places that I use formatters since this is a large code base.)
© Stack Overflow or respective owner