DateUtil.java
资源名称:cindyblog.rar [点击查看]
上传用户:cdpainuo
上传日期:2022-07-12
资源大小:5257k
文件大小:1k
源码类别:
Jsp/Servlet
开发平台:
Java
- package com.appspot.cindyblog.util;
- import java.text.SimpleDateFormat;
- import java.util.Date;
- public class DateUtil {
- private static SimpleDateFormat NOW_TIME = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- private static SimpleDateFormat NOW_DATE = new SimpleDateFormat("yyyy-MM-dd");
- private static SimpleDateFormat STR_TIME = new SimpleDateFormat("yyyyMMddHHmmsssss");
- public static String getDate(){
- Date date = new Date();
- return NOW_DATE.format(toChila(date));
- }
- public static String getDate(Date date){
- return NOW_DATE.format(toChila(date));
- }
- public static String getTime(){
- Date date = new Date();
- return NOW_TIME.format(toChila(date));
- }
- public static String getTime(Date date){
- return NOW_TIME.format(toChila(date));
- }
- public static String getStrTime(){
- Date date = new Date();
- return STR_TIME.format(toChila(date));
- }
- public static String getStrTime(Date date){
- return STR_TIME.format(toChila(date));
- }
- private static Date toChila(Date date){
- date.setHours(date.getHours()+8);
- return date;
- }
- }