📄 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;
import java.text.DateFormatSymbols;
import java.util.Calendar;
import java.util.Date;
import org.jfree.date.SerialDate;
/**
* 功能说明
* @version 1.0, 2006-10-8
* @author lvbo
*/
public class CommonDate {
/** 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;
}
/**
* Converts the specified string to a weekday, using the default locale.
*
* @param s a string representing the day-of-the-week.
*
* @return an integer representing the day-of-the-week.
*/
public int stringToWeekday(final String s) {
if (s.equals(this.weekdays[Calendar.SATURDAY])) {
return SerialDate.SATURDAY;
}
else if (s.equals(this.weekdays[Calendar.SUNDAY])) {
return SerialDate.SUNDAY;
}
else if (s.equals(this.weekdays[Calendar.MONDAY])) {
return SerialDate.MONDAY;
}
else if (s.equals(this.weekdays[Calendar.TUESDAY])) {
return SerialDate.TUESDAY;
}
else if (s.equals(this.weekdays[Calendar.WEDNESDAY])) {
return SerialDate.WEDNESDAY;
}
else if (s.equals(this.weekdays[Calendar.THURSDAY])) {
return SerialDate.THURSDAY;
}
else {
return SerialDate.FRIDAY;
}
}
/**
* 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);
return CALENDAR.getTime();
}
/**
* @param args
*/
public static void main(String[] args) {
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -