java 时间函數大全前段时间,做了一下 Java 的 util 包下的函数测试,觉得这个时间类的用法真多,不过也很简单,这里和大家分享一下
日期类import java
*;import java
*;import java
Calendar;public class VeDate {/*** 猎取现在时间** return 返回时间类型 yyyy-MM-dd HH:mm:ss*/public static Date getNowDate() {Date currentTime = new Date();SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");String dateString = formatter
format(currentTime);ParsePosition pos = new ParsePosition(8);Date currentTime_2 = formatter
parse(dateString, pos);return currentTime_2;}/*** 猎取现在时间** return 返回短时间格式 yyyy-MM-dd*/public static Date getNowDateShort() {Date currentTime = new Date();SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");String dateString = formatter
format(currentTime);ParsePosition pos = new ParsePosition(8);Date currentTime_2 = form