dqn8235 2017-07-31 07:51
浏览 188
已采纳

golang上的公历日历包

I m wrking on a project, and I want to make a date variable with the gregorian calendar in goLang, I've searched about it, but i didn't found an answer here is what i want to do with in golang in a java type code

try {
                final Calendar gc = new GregorianCalendar();
                gc.setTime(simpleDateFormat.parse(callEndDateTime));
                gc.add(Calendar.SECOND, -1 * duration);
                callStartDateTime = simpleDateFormat.format(gc.getTime());
            } catch (final ParseException parseException) {
                LOGGER.error("Couldn't parse the given date: " + callEndDateTime, parseException);
                callStartDateTime = null;
            }

thanks for helping me!

  • 写回答

2条回答 默认 最新

  • duan198727 2017-07-31 08:04
    关注

    You can make it as a string variable and than parse it.

    string strDate = "07 31 2017"; //example
    DateFormat df = new SimpleDateFormat("dd MM yyyy");
    Date date = df.parse(strDate);
    Calendar cal =  new GregorianCalendar();
    cal.setTime(date);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号