电脑桌面
添加小米粒文库到电脑桌面
安装后可以在桌面快捷访问

java时间函数大全

java时间函数大全_第1页
1/6
java时间函数大全_第2页
2/6
java时间函数大全_第3页
3/6
java 时间函數大全前段时间,做了一下 Java 的 util 包下的函数测试,觉得这个时间类的用法真多,不过也很简单,这里和大家分享一下。日期类import java.util.*;import java.text.*;import java.util.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 = formatter.parse(dateString, pos);return currentTime_2;}/*** 猎取现在时间** return 返回字符串格式 yyyy-MM-dd HH:mm:ss*/public static String getStringDate() {Date currentTime = new Date();SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");String dateString = formatter.format(currentTime);return dateString;}/*** 猎取现在时间** return 返回短时间字符串格式 yyyy-MM-dd*/public static String getStringDateShort() {Date currentTime = new Date();SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");String dateString = formatter.format(currentTime);return dateString;}/*** 猎取时间 小时:分;秒 HH:mm:ss** return*/public static String getTimeShort() {SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");Date currentTime = new Date();String dateString = formatter.format(currentTime);return dateString;}/*** 将长时间格式字符串转换为时间 yyyy-MM-dd HH:mm:ss** param strDate* return*/public static Date strToDateLong(String strDate) {SimpleDateFo...

1、当您付费下载文档后,您只拥有了使用权限,并不意味着购买了版权,文档只能用于自身使用,不得用于其他商业用途(如 [转卖]进行直接盈利或[编辑后售卖]进行间接盈利)。
2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。
3、如文档内容存在违规,或者侵犯商业秘密、侵犯著作权等,请点击“违规举报”。

碎片内容

java时间函数大全

确认删除?
VIP
微信客服
  • 扫码咨询
会员Q群
  • 会员专属群点击这里加入QQ群
客服邮箱
回到顶部