linux获取当前日期yyyymmdd,获取当前的日期
/****************************************************** 函数名: GetCurrentDate* 机能概要: 获取当前的日期** 参数: nFormat返回的格式* 0:"YYYYMMDD" 7:"DD/MM/YYYY"* 1:"YYYY/MM/DD" 8:"DD-MM-YYYY"* 2:"YYYY-MM-DD" 9:"DDMMYY"* 3:"YYMMDD" 10:"DD/MM/YY"* 4:"YY/MM/DD" 11:"DD-MM-YY"* 5:"YY-MM-DD" 12:"YYYY年MM月DD日"* 6:"DDMMYYYY" 13:"YY年MM月DD日"* 返回值: 指定格式的当前日期*********************************************************/
public static String GetCurrentDate(int nFormat){
String strReturnValue = "";
String strYear, strMonth, strDate;
GregorianCalendar GreDate = new GregorianCalendar();
strYear = new Integer(GreDate.get(GreDate.YEAR)).toString ();
strMonth = new Integer(GreDate.get(GreDate.MONTH) + 1).toString ();
strDate = new Integer(GreDate.get(GreDate.DATE)).toString ();
strReturnValue = GetFormatedDate(strYear,strMonth,strDate,nFormat);
return strReturnValue;
}
/****************************************************** 函数名: GetFormatedDate* 机能概要: 按照指定的格式转换日期** 参数: strYear有效的年份* strMonth有效的月份* strDate有效的日* nFormat指定的返回格式* 0:"YYYYMMDD" 7:"DD/MM/YYYY"* 1:"YYYY/MM/DD" 8:"DD-MM-YYYY"* 2:"YYYY-MM-DD" 9:"DDMMYY"* 3:"YYMMDD" 10:"DD/MM/YY"* 4:"YY/MM/DD" 11:"DD-MM-YY"* 5:"YY-MM-DD" 12:"YYYY年MM月DD日"* 6:"DDMMYYYY" 13:"YY年MM月DD日"* 返回值: 指定格式的日期*********************************************************/
public static String GetFormatedDate(String strYear, String strMonth,
String strDate, int nFormat)
{
String strReturnValue = "";
switch(nFormat){
case 0:
strReturnValue = SupplyLength(strYear,4) +
SupplyLength(strMonth,2) +
SupplyLength(strDate,2);
break;
case 1:
strReturnValue = SupplyLength(strYear,4) + "/" +
SupplyLength(strMonth,2) + "/" +
SupplyLength(strDate,2);
break;
case 2:
strReturnValue = SupplyLength(strYear,4) + "-" +
SupplyLength(strMonth,2) + "-" +
SupplyLength(strDate,2);
break;
case 3:
strReturnValue = SupplyLength(strYear,4).substring (2) +
SupplyLength(strMonth,2) +
SupplyLength(strDate,2);
break;
case 4:
strReturnValue = SupplyLength(strYear,4).substring (2) + "/" +
SupplyLength(strMonth,2) + "/" +
SupplyLength(strDate,2);
break;
case 5:
strReturnValue = SupplyLength(strYear,4).substring (2) + "-" +
SupplyLength(strMonth,2) + "-" +
SupplyLength(strDate,2);
break;
case 6:
strReturnValue = SupplyLength(strDate,2) +
SupplyLength(strMonth,2) +
SupplyLength(strYear,4);
break;
case 7:
strReturnValue = SupplyLength(strDate,2) + "/" +
SupplyLength(strMonth,2) + "/" +
SupplyLength(strYear,4);
break;
case 8:
strReturnValue = SupplyLength(strDate,2) + "-" +
SupplyLength(strMonth,2) + "-" +
SupplyLength(strYear,4);
break;
case 9:
strReturnValue = SupplyLength(strDate,2) +
SupplyLength(strMonth,2) +
SupplyLength(strYear,4).substring (2);
break;
case 10:
strReturnValue = SupplyLength(strDate,2) + "/" +
SupplyLength(strMonth,2) + "/" +
SupplyLength(strYear,4).substring (2);
break;
case 11:
strReturnValue = SupplyLength(strDate,2) + "-" +
SupplyLength(strMonth,2) + "-" +
SupplyLength(strYear,4).substring (2);
break;
case 12:
strReturnValue = SupplyLength(strYear, 4) + "年" +
SupplyLength(strMonth, 2) + "月" +
SupplyLength(strDate, 2) + "日";
break;
case 13:
strReturnValue = SupplyLength(strYear, 4).substring(2) + "年" +
SupplyLength(strMonth, 2) + "月" +
SupplyLength(strDate, 2) + "日";
break;
}
return strReturnValue;
}
linux获取当前日期yyyymmdd,获取当前的日期相关推荐
- Android 获取当前日期距离过期时间的日期差值的完整方法直接使用
/*** * 获取当前日期距离过期时间的日期差值 * @param endTime * @return */public String dateDiff(String endTime) { Strin ...
- 获取当前日期的三个月前的日期
获取当前日期的三个月前的日期 日期Api 1.思路 先获取当前时间戳 修改月份 返回修改后的时间戳 2.使用到的方法 setMonth() 方法用于设置月份. 注意: 一月为 0, 十二月为 11 这 ...
- java获取前四个季度结束日期_JAVA使用LocalDate获取当前日期所在季度的开始日期和结束日期...
需要使用jdk1.8及以上 /** * 获取当前日期所在季度的开始日期和结束日期 * 季度一年四季, 第一季度:1月-3月, 第二季度:4月-6月, 第三季度:7月-9月, 第四季度:10月-12月 ...
- SAP HANA SQL获取当前日期加若干天后的日期
前言部分 大家可以关注我的公众号,公众号里的排版更好,阅读更舒适. 正文部分 因为很多人问到HANA SQL的日期问题,我这里做了很多HANA函数的总结 更多讨论和资料请关注我的公众号:matinal ...
- vue获取当前日期以及前七天日期
一.获取当前日期: mounted () {this.getTime()}, getTime () {// new Date() new一个data对象,当前日期和时间// toLocaleStrin ...
- js获取当前日期及下一天日期
(网上到处都是,仅做记录,方便日后复用) 获取当前日期 格式 YY-MM-DD 获取指定日期的下一天日期 输入/返回 格式 YY-MM-DD 注:new Date()获取当前时间 new Date(d ...
- JavaScript 获取当前日期——JS 中的今天日期
在开发 Web 应用程序时,您可能需要包括执行特定操作的当前日期. 例如,当通过表单提交数据时,您可能希望包括数据的创建日期或提交表单的时间. 在本文中,我们将学习如何从头开始使用 JavaScrip ...
- java mil sec per day_java 获取当前日期 前10天的日期
下面都是获取当前日期 前10天(含当天)日期 的代码. Ctrl+c Ctrl+v 直接用. Calendar cal=Calendar.getInstance(); int year = cal.g ...
- JS获取当前日期,获取上个月的日期,一个月有多少天
小程序.H5 获取日期 // 获取时间不满两位补0formatTen: function (num) {return num > 9 ? (num + "") : (&quo ...
最新文章
- sql 基础--mysql 5 (6)
- 使用WinPcap和libpcap类库读写pcap文件(002)PCAP文件格式
- Ext.data.Connection
- 利用FreeNas创建WebDAV共享并实现ssl加密
- java 素数 五行_【数论】素数的判定与筛法
- 程序员Web面试之JSON
- 11.14PMP试题每日一题
- #我要上首页# 新版博客首页来了,做明星博主还会远吗?
- 汇编语言中变量的声明
- LAMP架构源码部署(入门级别超详细步骤)
- CentOS7或7以上,无iptable解决方法
- JavaC++题解与拓展——leetcode953.验证外星语【么的新知识】
- python培训班排行榜-重庆Python培训机构排行榜
- That's why you go away
- maven打包报错 Failed to execute goal org.apache.maven.plugins:maven-jar-plugin:3.0.2:jar
- 升级Android Studio 导致的 `Error:Failed to notify project evaluation listener.`解决办法
- ## 投标人出具哪种检测机构的报告才具有法律效力?
- Mathtype7安装包
- 这些实用技巧你会吗?
- android ndk开发中初始化char数组报错问题