java - Unexpected behavior of DateTimeFormatter of Joda Time? -
i expecting datetimeformatter return null or nothing if method 'public string print(readableinstant instant)' passed null datetime (which readableinstant.)
surprisingly returns current time instead of throwing error. bug ?
here related code -
import org.joda.time.*; import org.joda.time.format.datetimeformat; import org.joda.time.format.datetimeformatter; public class jodatest { public static void main(string[]args){ datetime dt = null; string ss = gettimeinaformat(dt); system.out.println(ss); } public static string gettimeinaformat(datetime time) { datetimeformatter dtf = datetimeformat.forpattern("mm-dd-yyyy hh:mm"); string datetime = dtf.print(time); // should throw error or return, return datetime; // string = "no date set" } }
it behaves documented:
parameters:
instant - instant format, null means
Comments
Post a Comment