private String getDate(String sformat) {
Date currentTime = new Date();
SimpleDateFormat formatter = new SimpleDateFormat(sformat);
String dateString = formatter.format(currentTime);
return dateString;
}
getDate("yyyy-MM-dd hh:mm:ss") 时候出错为啥 ,谢谢 java.lang.NullPointerException
------解决方案--------------------
这段代码没问题,可能其他地方问题。
------解决方案--------------------
这段代码没问题的,你debug一下,看看哪里报错