java - Javascript 有 Java 的日历辅助类吗?

标签 java javascript calendar

我正在尝试使用 Java 版本:

Date d = new Date(2010, Calendar.AUGUST, 28);

但在 JavaScript 中:

var d = new Date(2010, ???, 28);

我找不到包含月份常量的辅助类? Javascript 中是否存在 Java 帮助器 Calendar 类?

最佳答案

Javascript 不是 Java。 幸运的是,有像 datejs 这样的库.

Datejs is an open-source JavaScript Date Library.

Comprehensive, yet simple, stealthy and fast. Datejs has passed all trials and is ready to strike. Datejs doesn’t just parse strings, it slices them cleanly in two.

有关示例,请参阅 set() method :

set

.set ( Object config ) : Date

Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object.

// returns Jul 15 2008 18:45:30
Date.today().set({millisecond: 500, second: 30, minute: 45, hour: 18, day: 15, month: 6, year: 2008});

关于java - Javascript 有 Java 的日历辅助类吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3591292/

相关文章:

Javascript:在没有长度属性和切片的情况下获取字符串的长度

swift 中的 java.util.enumeration 等价物

javascript - React Native 第二次访问屏幕时 null is not a object (evaluating '_this2.state.data') 错误

java - patch 与 merge-patch 哪个更合适?

javascript - 是否可以暂停 Chrome/Opera 中的 svg 错误

android - 公历星期几

java - Java 日历操作的结果不一致

java - 将日期作为整数输入参数

java - Openjpa锁不起作用

java - 从 Youtube 中提取的评论数量是否有限制?