Show me code
记录各种功能的实现方式
Java
1、工具类私有化构造方法
private StringUtils() {
throw new IllegalStateException("Utility class");
}
2、获取前一个月的时间节点
// 输出的结果不正确
new Date(currentTimeMillis - 30 * 24 * 60 * 60 * 1000);
问题原因: 30 * 24 * 60 * 60 * 1000
的值已经超过了 int
的最大值,导致计算结果不正确。
解决方案: 只需要在 1000
加上 L
即可. new Date(currentTimeMillis - 30 * 24 * 60 * 60 * 1000L);