zoukankan      html  css  js  c++  java
  • Cannot format given Object as a Date

    java.lang.IllegalArgumentException: Cannot format given Object as a Date
    at java.text.DateFormat.format(DateFormat.java:310)
    at java.text.Format.format(Format.java:157)
    at com.nantian.sms.service.CoreOnLineTransactionService.findCoreTransactions(CoreOnLineTransactionService.java:103)
    at com.nantian.sms.service.CoreOnLineTransactionService.getCoreRealtimeData(CoreOnLineTransactionService.java:70)
    ==============================================================================================================================

    String transDate=otherMsg.substring(0,10);//********************************************************************************
    //交易日期 //2
    String strDateFormat = "yyyy-MM-dd";
    SimpleDateFormat sdf = new SimpleDateFormat(strDateFormat);

    //注意:这儿传入的应该是date;但是现在传入的是字符串
    String date=sdf.format(transDate);
    //应改为:
    Date tradeDate=sdf.parse(transDate) ;//解析为日期
    String date=sdf.format(tradeDate);//然后再格式化

  • 相关阅读:
    Redis
    Redis
    Redis
    linux 安装docker
    linux 安装nexus
    linux 安装jenkins
    linux 安装gitlab
    python 类的继承
    python raise & assert
    python super()
  • 原文地址:https://www.cnblogs.com/curedfisher/p/12230378.html
Copyright © 2011-2022 走看看