📄 commondate.java
字号:
/*
* @(#)AdviceProvKYBO.java 1.0 2006-10-08
*
* Copyright 2006 GE-SOFT, Inc. All rights reserved.
* GE-SOFT PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*
* 项目名称:ASPSERVICE
* 项目描述:“辽宁宽带商务综合服务平台”是基于J2EE三层结构,以MVC为技术框架,以
* Java技术 * 为开发技术的项目开发平台。采用面向对象和组件化的编程思想形成独立
* 的平台底层组 * 件,方便用户的二次开发。
*
* 制作记录: (日期 制作人 操作 描述)
* 2006-10-08 lvbo 建立 立项可研上报
*/
package com.common.commonLog;
import java.awt.Color;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.text.DateFormatSymbols;
import java.util.Calendar;
import java.util.Date;
import com.common.commonLog.Log;
import com.common.commonLog.LogContext;
import com.common.commonLog.PrintStreamLogTarget;
/**
* 功能说明
* @version 1.0, 2006-10-8
* @author lvbo
*/
public class CommonDate {
private static final LogContext LOGGER = Log.createContext(CommonDate.class);
/** A working calendar. */
private static final Calendar CALENDAR = Calendar.getInstance();
/** The default date format symbols. */
private DateFormatSymbols dateFormatSymbols;
/** Strings representing the weekdays. */
private String[] weekdays;
/** Strings representing the months. */
private String[] months;
/**
* Creates a new utility class for the default locale.
*/
public CommonDate() {
this.dateFormatSymbols = new DateFormatSymbols();
this.weekdays = this.dateFormatSymbols.getWeekdays();
this.months = this.dateFormatSymbols.getMonths();
}
/**
* Returns an array of strings representing the days-of-the-week.
*
* @return an array of strings representing the days-of-the-week.
*/
public String[] getWeekdays() {
return this.weekdays;
}
/**
* Returns an array of strings representing the months.
*
* @return an array of strings representing the months.
*/
public String[] getMonths() {
return this.months;
}
/**
* Creates a date.
*
* @param yyyy the year.
* @param month the month (1 - 12).
* @param day the day.
*
* @return a date.
*/
public static synchronized Date createDate(final int yyyy, final int month, final int day) {
CALENDAR.clear();
CALENDAR.set(yyyy, month - 1, day);
return CALENDAR.getTime();
}
/**
* Creates a date.
*
* @param yyyy the year.
* @param month the month (1 - 12).
* @param day the day.
* @param hour the hour.
* @param min the minute.
*
* @return a date.
*/
public static synchronized Date createDate(final int yyyy, final int month, final int day, final int hour, final int min) {
CALENDAR.clear();
CALENDAR.set(yyyy, month - 1, day, hour, min);
LOGGER.debug("yyyy = " + yyyy + ", month=" + month);
return CALENDAR.getTime();
}
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
try {
//FileWriter p_file = new FileWriter("D:\\tt.txt", true);
FileOutputStream fos = new FileOutputStream("D:\\tt.txt",true);
//BufferedWriter reader= new BufferedWriter(fos, "");
/** Access to logging facilities. */
Log.getInstance().addTarget(new PrintStreamLogTarget(new PrintStream(fos)));
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.print(CommonDate.createDate(2006,11,28,22,38));
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -