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 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题