- /**
- * 英文简写(默认)如:2010-12-01
- */
- public static String FORMAT_SHORT = "yyyy-MM-dd";
-
- /**
- * 英文全称 如:2010-12-01 23:15:06
- */
- public static String FORMAT_LONG = "yyyy-MM-dd HH:mm:ss";
-
- /**
- * 精确到毫秒的完整时间 如:yyyy-MM-dd HH:mm:ss.S
- */
- public static String FORMAT_FULL = "yyyy-MM-dd HH:mm:ss.S";
-
- /**
- * 中文简写 如:2010年12月01日
- */
- public static String FORMAT_SHORT_CN = "yyyy年MM月dd";
-
- /**
- * 中文全称 如:2010年12月01日 23时15分06秒
- */
- public static String FORMAT_LONG_CN = "yyyy年MM月dd日 HH时mm分ss秒";
-
- /**
- * 精确到毫秒的完整中文时间
- */
- public static String FORMAT_FULL_CN = "yyyy年MM月dd日 HH时mm分ss秒SSS毫秒";
-
- /**
- * 获取时间戳
- */
- public static String getTimeString() {
- SimpleDateFormat df = new SimpleDateFormat(FORMAT_FULL);
- Calendar calendar = Calendar.getInstance();
- return df.format(calendar.getTime());
- }
-
- /**
- * 获取日期年份
- * @param date 日期
- * @return
- */
- public static String getYear(Date date) {
- return format(date).substring(0, 4);
- }
- /**
- * 功能描述:返回月
- *
- * @param date
- * Date 日期
- * @return 返回月份
- */
- public static int getMonth(Date date) {
- calendar = Calendar.getInstance();
- calendar.setTime(date);
- return calendar.get(Calendar.MONTH) + 1;
- }
-
- /**
- * 功能描述:返回日
- *
- * @param date
- * Date 日期
- * @return 返回日份
- */
- public static int getDay(Date date) {
- calendar = Calendar.getInstance();
- calendar.setTime(date);
- return calendar.get(Calendar.DAY_OF_MONTH);
- }
-
- /**
- * 功能描述:返回小
- *
- * @param date
- * 日期
- * @return 返回小时
- */
- public static int getHour(Date date) {
- calendar = Calendar.getInstance();
- calendar.setTime(date);
- return calendar.get(Calendar.HOUR_OF_DAY);
- }
-
- /**
- * 功能描述:返回分
- *
- * @param date
- * 日期
- * @return 返回分钟
- */
- public static int getMinute(Date date) {
- calendar = Calendar.getInstance();
- calendar.setTime(date);
- return calendar.get(Calendar.MINUTE);
- }
-
- /**
- * 返回秒钟
- *
- * @param date
- * Date 日期
- * @return 返回秒钟
- */
- public static int getSecond(Date date) {
- calendar = Calendar.getInstance();
- calendar.setTime(date);
- return calendar.get(Calendar.SECOND);
- }
-
- /**
- * 功能描述:返回毫
- *
- * @param date
- * 日期
- * @return 返回毫
- */
- public static long getMillis(Date date) {
- calendar = Calendar.getInstance();
- calendar.setTime(date);
- return calendar.getTimeInMillis();
- }
public static String FORMAT_SHORT = "yyyy-MM-dd" ; |
* 英文全称 如:2010-12-01 23:15:06 |
public static String FORMAT_LONG = "yyyy-MM-dd HH:mm:ss" ; |
* 精确到毫秒的完整时间 如:yyyy-MM-dd HH:mm:ss.S |
public static String FORMAT_FULL = "yyyy-MM-dd HH:mm:ss.S" ; |
public static String FORMAT_SHORT_CN = "yyyy年MM月dd" ; |
* 中文全称 如:2010年12月01日 23时15分06秒 |
public static String FORMAT_LONG_CN = "yyyy年MM月dd日 HH时mm分ss秒" ; |
public static String FORMAT_FULL_CN = "yyyy年MM月dd日 HH时mm分ss秒SSS毫秒" ; |
public static String getTimeString() { |
SimpleDateFormat df = new SimpleDateFormat(FORMAT_FULL); |
Calendar calendar = Calendar.getInstance(); |
return df.format(calendar.getTime()); |
public static String getYear(Date date) { |
return format(date).substring( 0 , 4 ); |
public static int getMonth(Date date) { |
calendar = Calendar.getInstance(); |
return calendar.get(Calendar.MONTH) + 1 ; |
public static int getDay(Date date) { |
calendar = Calendar.getInstance(); |
return calendar.get(Calendar.DAY_OF_MONTH); |
public static int getHour(Date date) { |
calendar = Calendar.getInstance(); |
return calendar.get(Calendar.HOUR_OF_DAY); |
public static int getMinute(Date date) { |
calendar = Calendar.getInstance(); |
return calendar.get(Calendar.MINUTE); |
public static int getSecond(Date date) { |
calendar = Calendar.getInstance(); |
return calendar.get(Calendar.SECOND); |
public static long getMillis(Date date) { |
calendar = Calendar.getInstance(); |
return calendar.getTimeInMillis(); |
- oracle截取时间的年/月/日/时/分/秒
修改日期格式为年月日时分秒: alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';select to_char(sysdate,'yyy ...
- ASP.NET C# 日期 时间 年 月 日 时 分 秒 格式及转换(转自happymagic的专栏)
在平时编码中,经常要把日期转换成各种各样的形式输出或保持,今天专门做了个测试,发现DateTime的ToString()方法居然有这么多的表现形式,和大家一起分享. DateTime time=Dat ...
- ASP.NET 日期 时间 年 月 日 时 分 秒 格式及转换
在平时编码中,经常要把日期转换成各种各样的形式输出或保持,今天专门做了个测试,发现DateTime的ToString()方法居然有这么多的表现形式,和大家一起分享. DateTime time=Dat ...
- ASP.NET C# 获取当前日期 时间 年 月 日 时 分 秒
我们可以通过使用DataTime这个类来获取当前的时间.通过调用类中的各种方法我们可以获取不同的时间:如:日期(2008-09-04).时间(12:12:12).日期+时间(2008-09-04 12 ...
- [Windows]获取当前时间(年/月/日/时/分/秒)
struct tm* GetCurTime(time_t inTime) { struct tm* curTime = localtime(&inTime); curTime->tm_y ...
- mysql 获取系统时间的下一天 年-月-日 时:分:秒
DAY) as date
- C#WinForm中显示实时时间:年/月/日 时/分/秒 星期X
//加载窗体时 string weekstr = ""; private void Form22_Load(object sender, EventArgs e) { this.t ...
- Js 日期字符串分别截取 年 月 日 时 分 秒
function shijiantime(times){ var timearr = times.replace(" ", ":").replace(/\:/g ...
- js将当前时间格式化为年-月-日 时:分:秒
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
随机推荐
- [js高手之路] es6系列教程 - new.target属性与es5改造es6的类语法
es5的构造函数前面如果不用new调用,this指向window,对象的属性就得不到值了,所以以前我们都要在构造函数中通过判断this是否使用了new关键字来确保普通的函数调用方式都能让对象复制到属性 ...
- vue2.0 配置sass
一.配置sass依赖 npm install node-sass --save-dev npm install sass-loader --save-dev 二.打开build文件夹下的webpack ...
- 横向、纵向时间轴timeline系列
近期移动端项目用到了很多时间轴.纵向的.开始可以实现,但是不利于维护.整理下, 以作为备份留存学习参考.子元素的 标签的 :before实现圆点,:after实现边线border纵向时间轴,单一右边内 ...
- Java学习笔记12(面向对象五:构造方法、this再探)
在开发中,经常需要在创建对象的同时明确对象对的属性值, 比如一个Person对象创建时候就应该有age和name等属性 那么如何做到在创建对象的同时给对象的属性初始化值呢? 这里介绍构造方法: 1.构 ...
- COM学习(二)——COM的注册和卸载
COM组件是跨语言的,组件被注册到注册表中,在加载时由加载函数在注册表中查找到对应模块的路径并进行相关加载.它的存储规则如下: 1. 在注册表的HKEY_CLASSES_ROOT中以模块名的方式保存着 ...
- 一些关于memcpy memmove函数的区别,和模拟实现
memcpy: 它是c和c++使用的内存拷贝函数,memcpy函数的功能是从源src所指的内存地址的起始位置开始拷贝n个字节到目标dest所指的内存地址的起始位置中. 函数原型:void* memcp ...
- Keepalived概述和安装(1)
一.Keepalived概述 本文主要了解开源高可用负载均衡集群利器keepalived,掌握keepalived的安装,运用keepalived配置高可用集群,并能够实现keepalived与负载均 ...
- Spring MVC 详解之废话少说
<陈翔六点半之废话少说>.... Spring WEB MVC 的请求流程: Spring WEB MVC架构: 开始创建.配置gradle项目 1.在gralde项目中,选择SDK 和框 ...
- Mac从零配置Vim
// 这是一篇导入进来的旧博客,可能有时效性问题. 1. 安装Homebrew (包管理器,用来安装Vim)& /usr/bin/ruby -e "$(curl -fsSL http ...
- 【Java学习笔记之三】java中的变量和常量
变量和常量 在程序中存在大量的数据来代表程序的状态,其中有些数据在程序的运行过程中值会发生改变,有些数据在程序运行过程中值不能发生改变,这些数据在程序中分别被叫做变量和常量. 在实际的程序中,可以根据 ...