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

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -