开发者社区> 问答> 正文

JAVA 取值问题(Date和String,long转换)

  SimpleDateFormat lst = new SimpleDateFormat("yyyy-MM-dd");
        TransLogInfo transLogInfo = transLogInfoService.QueryTransLogInfo("intTxnDt");
        String log = transLogInfo.getIntTxnDt();
        Date logTime =lst.parse(log);
        GregorianCalendar gc=new GregorianCalendar(); 
        gc.setTime(logTime);

我想把数据库里的时间取出来,和当前时间进行比较,可是这段代码在运行的时候出现了问题
Error calling method through OGNL:
报的错误好像是“String log = transLogInfo.getIntTxnDt()”不能这得到,空指针错误.

展开
收起
蛮大人123 2016-03-13 19:12:16 2556 0
2 条回答
写回答
取消 提交回答
  • new date

    2019-07-17 19:03:04
    赞同 展开评论 打赏
  • 我说我不帅他们就打我,还说我虚伪
    SimpleDateFormat lst = new SimpleDateFormat("yyyy-MM-dd");
    TransLogInfo transLogInfo = transLogInfoService.QueryTransLogInfo("intTxnDt");
    if(transLogInfo != null){
    String log = transLogInfo.getIntTxnDt();
    }
        Date logTime =lst.parse(log);
        GregorianCalendar gc=new GregorianCalendar(); 
        gc.setTime(logTime);
    2019-07-17 19:03:04
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
Spring Cloud Alibaba - 重新定义 Java Cloud-Native 立即下载
The Reactive Cloud Native Arch 立即下载
JAVA开发手册1.5.0 立即下载