⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dateformatter.java

📁 管理公司合同
💻 JAVA
字号:

/*
 * Created on 2005-11-4 9:52:07
 *
 * By SinoBest
 * Copyright E3.org, 2005-2006, All rights reserved.
 */

package cn.com.juneng.system.common;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 *	用来格式化日期格式
 *		
 * @author wutao
 *
 */

public class DateFormatter
{
	protected static final Log log = LogFactory.getLog(DateFormatter.class);
	
	private static String formatDate = "yyyyMMdd";
	private static String formatDateTime = "yyyyMMdd HH:mm:ss";
	private static String formatDateTime2 = "yyyy-MM-dd HH:mm:ss";
	private static String formatYear = "yyyy";
	private static String formatYearMonth = "yyyyMM";
	
	private static SimpleDateFormat sdfDate = new SimpleDateFormat(formatDate);
	private static SimpleDateFormat sdfDateTime = new SimpleDateFormat(formatDateTime);
	private static SimpleDateFormat sdfDateTime2 = new SimpleDateFormat(formatDateTime2);
	private static SimpleDateFormat sdfDateTime3 = new SimpleDateFormat(formatYear);
	private static SimpleDateFormat sdfDateTime4 = new SimpleDateFormat(formatYearMonth);
	

	public static String formatDate(Date date)
	{
		if(date == null)
			return "";
		return sdfDate.format(date);
	}
	
	public static String formatDateTime(Date date)
	{
		if(date == null)
			return "";
		return sdfDateTime.format(date);
	}
	public static String formatDateTime2(Date date)
	{
		if(date == null)
			return "";
		return sdfDateTime2.format(date);
	}
	public static String formatDateTime4(Date date)
	{
		if(date == null)
			return "";
		return sdfDateTime4.format(date);
	}
	public static String formatDateTime3(Date date)
	{
		if(date == null)
			return "";
		return sdfDateTime3.format(date);
	}
	public static SimpleDateFormat getDateFormat()
	{
		return sdfDate;
	}
	
	public static SimpleDateFormat getYearFormat(){
		return  sdfDateTime3;
	}
	
	public static SimpleDateFormat getYearMonthFormat(){
		return sdfDateTime4;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -