Golang上的公历日历包

布布·埃拉姆里:

我在一个项目中工作,我想用goLang中的公历创建一个日期变量,我已经搜索了它,但是我没有找到答案,这是我想在java中的golang中做什么输入代码

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;
            }

感谢您的帮助!

Indrit Kello:

您可以将其设置为字符串变量,然后进行解析。

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);

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章