/**
* all rights reserved by zhanqiong, 2005
*/
package
com.koubei.util;
import
java.text.DateFormat;
import
java.text.ParseException;
import
java.text.SimpleDateFormat;
import
java.util.ArrayList;
import
java.util.Calendar;
import
java.util.Date;
import
java.util.List;
/**
* @author chen
*
*/
public
class
DateUtil {
/**
* 日
*/
public
final
static
int
INTERVAL_DAY =
1
;
/**
* 周
*/
public
final
static
int
INTERVAL_WEEK =
2
;
/**
* 月
*/
public
final
static
int
INTERVAL_MONTH =
3
;
/**
* 年
*/
public
final
static
int
INTERVAL_YEAR =
4
;
/**
* 小时
*/
public
final
static
int
INTERVAL_HOUR =
5
;
/**
* 分钟
*/
public
final
static
int
INTERVAL_MINUTE =
6
;
/**
* 秒
*/
public
final
static
int
INTERVAL_SECOND =
7
;
/**
* date = 1901-01-01
*/
public
final
static
Date tempDate=
new
Date(
new
Long(
"-2177481952000"
));;
/**
* 测试是否是当天
*
* @param date - 某一日期
* @return true-今天, false-不是
*/
@SuppressWarnings
(
"deprecation"
)
public
static
boolean
isToday(Date date) {
Date now =
new
Date();
boolean
result =
true
;
result &= date.getYear()==now.getYear();
result &= date.getMonth()==now.getMonth();
result &= date.getDate()==now.getDate();
return
result;
}
/**
* 两个日期相减,取天数
*
* @param date1
* @param date2
* @return
*/
public
static
long
DaysBetween(Date date1, Date date2) {
if
(date2 ==
null
)
date2 =
new
Date();
long
day = (date2.getTime() - date1.getTime()) / (
24
*
60
*
60
*
1000
);
return
day;
}
/**
* 比较两个日期 if date1<=date2 return true
*
* @param date1
* @param date2
* @return
*/
public
static
boolean
compareDate(String date1, String date2) {
SimpleDateFormat format =
new
SimpleDateFormat(
"yyyy-MM-dd"
);
try
{
Date d1 = format.parse(date1);
Date d2 = format.parse(date2);
return
!d1.after(d2);
}
catch
(ParseException e) {
e.printStackTrace();
return
false
;
}
}
/**
* 字符型转换成日期型
*
* @param date
* @param dateFormat
* @return
*/
public
static
Date dateFormat(String date, String dateFormat) {
if
(date ==
null
)
return
null
;
SimpleDateFormat format =
new
SimpleDateFormat(dateFormat);
if
(date !=
null
) {
try
{
return
format.parse(date);
}
catch
(Exception ex) {
}
}
return
null
;
}
/**
* 使用默认格式 yyyy-MM-dd HH:mm:ss
* @author Robin Chang
* @param date
* @return
*/
public
static
Date dateFormat(String date)
{
return
dateFormat(date,
"yyyy-MM-dd HH:mm:ss"
);
}
/**
* 日期型转换成字符串
*
* @param date
* @param dateFormat
* @return
*/
public
static
String dateFormat(Date date, String dateFormat) {
if
(date ==
null
)
return
""
;
SimpleDateFormat format =
new
SimpleDateFormat(dateFormat);
if
(date !=
null
) {
return
format.format(date);
}
return
""
;
}
/**
* 由于生日增加保密属性,现决定1900为保密对应值,如果遇到1900的年份,则隐掉年份
*
* @param date
* @param dateFormat
* @return 不保密显示1981-12-01保密则显示`12-01
*/
public
static
String birthdayFormat(Date date) {
if
(date ==
null
)
return
""
;
SimpleDateFormat format =
null
;
if
(date.before(tempDate)) {
format =
new
SimpleDateFormat(
"MM-dd"
);
}
else
{
format =
new
SimpleDateFormat(
"yyyy-MM-dd"
);
}
if
(date !=
null
) {
return
format.format(date);
}
return
""
;
}
/**
* 使用默认格式 yyyy-MM-dd HH:mm:ss
* @param date
* @return
*/
public
static
String dateFormat(Date date)
{
return
dateFormat(date,
"yyyy-MM-dd HH:mm:ss"
);
}
public
static
boolean
isExpiredDay(Date date1) {
long
day = (
new
Date().getTime() - date1.getTime()) / (
24
*
60
*
60
*
1000
);
if
(day >=
1
)
return
true
;
else
return
false
;
}
public
static
Date getYesterday() {
Date date =
new
Date();
long
time = (date.getTime() /
1000
) -
60
*
60
*
24
;
date.setTime(time *
1000
);
SimpleDateFormat format =
new
SimpleDateFormat(
"yyyy-MM-dd"
);
try
{
date = format.parse(format.format(date));
}
catch
(Exception ex) {
System.out.println(ex.getMessage());
}
return
date;
}
public
static
Date getWeekAgo() {
Date date =
new
Date();
long
time = (date.getTime() /
1000
) -
7
*
60
*
60
*
24
;
date.setTime(time *
1000
);
SimpleDateFormat format =
new
SimpleDateFormat(
"yyyy-MM-dd"
);
try
{
date = format.parse(format.format(date));
}
catch
(Exception ex) {
System.out.println(ex.getMessage());
}
return
date;
}
public
static
String getDaysAgo(
int
interval) {
Date date =
new
Date();
long
time = (date.getTime() /
1000
) - interval *
60
*
60
*
24
;
date.setTime(time *
1000
);
SimpleDateFormat format =
new
SimpleDateFormat(
"yyyy-MM-dd"
);
try
{
return
format.format(date);
}
catch
(Exception ex) {
System.out.println(ex.getMessage());
}
return
""
;
}
public
static
Date getTomorrow() {
Date date =
new
Date();
long
time = (date.getTime() /
1000
) +
60
*
60
*
24
;
date.setTime(time *
1000
);
SimpleDateFormat format =
new
SimpleDateFormat(
"yyyy-MM-dd"
);
try
{
date = format.parse(format.format(date));
}
catch
(Exception ex) {
System.out.println(ex.getMessage());
}
return
date;
}
public
static
Date getBeforeDate(String range) {
Calendar today = Calendar.getInstance();
if
(
"week"
.equalsIgnoreCase(range))
today.add(Calendar.WEEK_OF_MONTH, -
1
);
else
if
(
"month"
.equalsIgnoreCase(range))
today.add(Calendar.MONTH, -
1
);
else
today.clear();
return
today.getTime();
}
public
static
Date getThisWeekStartTime() {
Calendar today = Calendar.getInstance();
today.set(Calendar.DAY_OF_WEEK, today.getFirstDayOfWeek());
Calendar weekFirstDay = Calendar.getInstance();
weekFirstDay.clear();
weekFirstDay.set(Calendar.YEAR, today.get(Calendar.YEAR));
weekFirstDay.set(Calendar.MONTH, today.get(Calendar.MONTH));
weekFirstDay.set(Calendar.DATE, today.get(Calendar.DATE));
return
weekFirstDay.getTime();
}
public
static
String getToday(String format) {
String result =
""
;
try
{
Date today =
new
Date();
SimpleDateFormat simpleFormat =
new
SimpleDateFormat(format);
result = simpleFormat.format(today);
}
catch
(Exception e) {
}
return
result;
}
public
static
Date getStartDay(
int
year,
int
month) {
Calendar today = Calendar.getInstance();
today.clear();
today.set(Calendar.YEAR, year);
today.set(Calendar.MONTH, month -
1
);
today.set(Calendar.DAY_OF_MONTH,
1
);
return
today.getTime();
}
public
static
List<Integer> getBeforeYearList(
int
before) {
Calendar today = Calendar.getInstance();
int
theYear = today.get(Calendar.YEAR);
List<Integer> list =
new
ArrayList<Integer>();
for
(
int
i = before; i >=
0
; i--)
list.add(theYear - i);
return
list;
}
/**
* 增加时间
* @param interval [INTERVAL_DAY,INTERVAL_WEEK,INTERVAL_MONTH,INTERVAL_YEAR,INTERVAL_HOUR,INTERVAL_MINUTE]
* @param date
* @param n 可以为负数
* @return
*/
public
static
Date dateAdd(
int
interval,Date date,
int
n)
{
long
time = (date.getTime() /
1000
);
switch
(interval)
{
case
INTERVAL_DAY:
time = time + n *
86400
;
break
;
case
INTERVAL_WEEK:
time = time + n *
604800
;
break
;
case
INTERVAL_MONTH:
time = time + n *
2678400
;
break
;
case
INTERVAL_YEAR:
time = time + n *
31536000
;
break
;
case
INTERVAL_HOUR:
time = time + n *
3600
;
break
;
case
INTERVAL_MINUTE:
time = time + n *
60
;
break
;
case
INTERVAL_SECOND:
time = time + n;
break
;
default
:
}
Date result =
new
Date();
result.setTime(time *
1000
);
return
result;
}
/**
* 计算两个时间间隔
* @param interval [INTERVAL_DAY,INTERVAL_WEEK,INTERVAL_MONTH,INTERVAL_YEAR,INTERVAL_HOUR,INTERVAL_MINUTE]
* @param begin
* @param end
* @return
*/
public
static
int
dateDiff(
int
interval,Date begin,Date end)
{
long
beginTime = (begin.getTime() /
1000
);
long
endTime = (end.getTime() /
1000
);
long
tmp =
0
;
if
(endTime == beginTime)
{
return
0
;
}
if
(endTime < beginTime)
{
tmp = beginTime;
beginTime = endTime;
endTime = tmp;
}
long
intervalTime = endTime - beginTime;
long
result =
0
;
switch
(interval)
{
case
INTERVAL_DAY:
result = intervalTime /
86400
;
break
;
case
INTERVAL_WEEK:
result = intervalTime /
604800
;
break
;
case
INTERVAL_MONTH:
result = intervalTime /
2678400
;
break
;
case
INTERVAL_YEAR:
result = intervalTime /
31536000
;
break
;
case
INTERVAL_HOUR:
result = intervalTime /
3600
;
break
;
case
INTERVAL_MINUTE:
result = intervalTime /
60
;
break
;
case
INTERVAL_SECOND:
result = intervalTime /
1
;
break
;
default
:
}
if
(tmp >
0
)
{
result =
0
- result;
}
return
(
int
) result;
}
/**
* 当前年份
* @return
*/
public
static
int
getTodayYear()
{
int
yyyy = Integer.parseInt(dateFormat(
new
Date(),
"yyyy"
));
return
yyyy;
}
public
static
Date getNow()
{
return
new
Date();
}
/**
* 把日期格式为rss格式兼容的字符串
* @param date
* @return
*/
public
static
String dateFormatRss(Date date)
{
if
(date !=
null
)
{
return
dateFormat(date,
"E, d MMM yyyy H:mm:ss"
) +
" GMT"
;
}
return
""
;
}
/**
* 判断当前日期是否在两个日期之间
* @param startDate 开始时间
* @param endDate 结束时间
* @return
*/
public
static
boolean
betweenStartDateAndEndDate(Date startDate,Date endDate){
boolean
bool=
false
;
Date curDate=
new
Date();
if
(curDate.after(startDate) && curDate.before(DateUtil.dateAdd( INTERVAL_DAY ,endDate,
1
)) ){
bool=
true
;
}
return
bool;
}
/**
* 判断当前时间是否在在两个时间之间
* @param startDate 开始时间
* @param endDate 结束时间
* @return
*/
public
static
boolean
nowDateBetweenStartDateAndEndDate(Date startDate,Date endDate){
boolean
bool=
false
;
Date curDate=
new
Date();
if
(curDate.after(startDate) && curDate.before(endDate)){
bool=
true
;
}
return
bool;
}
/**
* 判断当前时间是否在date之后
* @param date
* @return
*/
public
static
boolean
nowDateAfterDate(Date date){
boolean
bool=
false
;
Date curDate=
new
Date();
if
(curDate.after(date)){
bool=
true
;
}
return
bool;
}
/**
* 判断二个日期相隔的天数,结束时间为null时,,取当前时间
* @param startDate 开始时间
* @param endDate 结束时间
* @return
*/
public
static
int
getBetweenTodaysStartDateAndEndDate(Date startDate,Date endDate){
int
betweentoday =
0
;
if
(startDate==
null
){
return
betweentoday;
}
if
(endDate==
null
){
Calendar calendar = Calendar.getInstance();
String year =
new
Integer(calendar.get(Calendar.YEAR)).toString();
String month =
new
Integer((calendar.get(calendar.MONTH)+
1
)).toString();
String day =
new
Integer(calendar.get(calendar.DAY_OF_MONTH)).toString();
String strtodaytime = year+
"-"
+month+
"-"
+day;
DateFormat formatter=
new
SimpleDateFormat(
"yyyy-MM-dd"
);
try
{
endDate = formatter.parse(strtodaytime);
}
catch
(ParseException e) {
e.printStackTrace();
}
}
if
(endDate.after(startDate)){
betweentoday = (
int
)((endDate.getTime() -startDate.getTime())/
86400000
);
}
else
{
betweentoday = (
int
)((startDate.getTime() -endDate.getTime())/
86400000
);
}
return
betweentoday;
}
/**
* 取得指定长度日期时间字符串{不含格式}
@param format 时间格式由常量决定
8: YYMMDDHH 8位
10: YYMMDDHHmm 10位
12: YYMMDDHHmmss 12位
14: YYYYMMDDHHmmss 14位
15: YYMMDDHHmmssxxx 15位 (最后的xxx 是毫秒)
*/
public
static
String getTime(
int
format){
StringBuffer cTime=
new
StringBuffer(
10
);
Calendar time=Calendar.getInstance();
int
miltime=time.get(Calendar.MILLISECOND);
int
second=time.get(Calendar.SECOND);
int
minute=time.get(Calendar.MINUTE);
int
hour=time.get(Calendar.HOUR_OF_DAY);
int
day =time.get(Calendar.DAY_OF_MONTH);
int
month=time.get(Calendar.MONTH)+
1
;
int
year =time.get(Calendar.YEAR);
if
(format!=
14
){
if
(year>=
2000
) year=year-
2000
;
else
year=year-
1900
;
}
if
(format>=
2
){
if
(format==
14
) cTime.append(year);
else
cTime.append(getFormatTime(year,
2
));
}
if
(format>=
4
)
cTime.append(getFormatTime(month,
2
));
if
(format>=
6
)
cTime.append(getFormatTime(day,
2
));
if
(format>=
8
)
cTime.append(getFormatTime(hour,
2
));
if
(format>=
10
)
cTime.append(getFormatTime(minute,
2
));
if
(format>=
12
)
cTime.append(getFormatTime(second,
2
));
if
(format>=
15
)
cTime.append(getFormatTime(miltime,
3
));
return
cTime.toString();
}
/**
* 产生任意位的字符串
* @param time 要转换格式的时间
* @param format 转换的格式
* @return String 转换的时间
*/
private
static
String getFormatTime(
int
time,
int
format){
StringBuffer numm=
new
StringBuffer();
int
length=String.valueOf(time).length();
if
(format<length)
return
null
;
for
(
int
i=
0
;i<format-length ;i++){
numm.append(
"0"
);
}
numm.append(time);
return
numm.toString().trim();
}
/**
* 根据生日去用户年龄
* @param birthday
* @return int
* @exception
* @author 豆皮
* @Date Apr 24, 2008
*/
public
static
int
getUserAge(Date birthday){
if
(birthday ==
null
)
return
0
;
Calendar cal = Calendar.getInstance();
if
(cal.before(birthday)) {
return
0
;
}
int
yearNow = cal.get(Calendar.YEAR);
cal.setTime(birthday);
int
yearBirth = cal.get(Calendar.YEAR);
return
yearNow - yearBirth;
}
/**
* 将int型时间(1970年至今的秒数)转换成Date型时间
* @param unixTime 1970年至今的秒数
* @return
* @author 郑卿
*/
public
static
Date getDateByUnixTime(
int
unixTime){
return
new
Date(unixTime*1000L);
}
/**
* 将Date型时间转换成int型时间(1970年至今的秒数)
* @param unixTime 1970年至今的秒数
* @return
* @author 郑卿
*/
public
static
int
getUnixTimeByDate(Date date){
return
(
int
)(date.getTime()/
1000
);
}
public
static
void
main(String[] args) {
Date date1 =dateFormat(
"1981-01-01 00:00:00"
);
Date date2 =dateFormat(
"1900-12-31 00:00:00"
);
System.out.println(birthdayFormat(date1));
System.out.println(birthdayFormat(date2));
}
public
static
Date getNextDay(Date date) {
long
time = (date.getTime() /
1000
) +
60
*
60
*
24
;
date.setTime(time *
1000
);
SimpleDateFormat format =
new
SimpleDateFormat(
"yyyy-MM-dd"
);
try
{
date = format.parse(format.format(date));
}
catch
(Exception ex) {
System.out.println(ex.getMessage());
}
return
date;
}
/**
* @param date
* @return
* 复制新Date,不改变参数
*/
public
static
Date nextDay(Date date) {
Date newDate = (Date) date.clone();
long
time = (newDate.getTime() /
1000
) +
60
*
60
*
24
;
newDate.setTime(time *
1000
);
SimpleDateFormat format =
new
SimpleDateFormat(
"yyyy-MM-dd"
);
try
{
newDate = format.parse(format.format(newDate));
}
catch
(Exception ex) {
System.out.println(ex.getMessage());
}
return
newDate;
}
@SuppressWarnings
(
"unused"
)
public
static
Date getNowTime() {
SimpleDateFormat format =
new
SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss"
);
Date date =
new
Date();
String dateStr = dateFormat(date);
try
{
date = format.parse(dateStr);
}
catch
(ParseException e) {
e.printStackTrace();
}
return
date;
}
public
static
Date getTomorrow(Date date1) {
Calendar now = Calendar.getInstance();
now.setTime(date1);
now.add(Calendar.DATE,
1
);
return
now.getTime();
}
public
static
Date getWeekAgo(Date date) {
Date newDate = (Date) date.clone();
long
time = (newDate.getTime() /
1000
) -
60
*
60
*
24
*
7
;
newDate.setTime(time *
1000
);
SimpleDateFormat format =
new
SimpleDateFormat(
"yyyy-MM-dd"
);
try
{
newDate = format.parse(format.format(newDate));
}
catch
(Exception ex) {
System.out.println(ex.getMessage());
}
return
newDate;
}
public
static
Date getDatebyTime(Date date,
int
n) {
String str = DateUtil.dateFormat(date,
"yyyy-MM-dd"
);
String[] strs = str.split(
"-"
);
int
month = Integer.parseInt(strs[
1
]);
int
monthnow = (month + n) %
12
;
int
year = Integer.parseInt(strs[
0
]) + (month + n) /
12
;
str = String.valueOf(year) +
"-"
+ String.valueOf(monthnow) +
"-"
+ strs[
2
];
return
DateUtil.dateFormat(str,
"yyyy-MM-dd"
);
}
/**
* @param date
* @return
* 复制新Date,不改变参数
*/
public
static
Date yesterday(Date date) {
Date newDate = (Date) date.clone();
long
time = (newDate.getTime() /
1000
) -
60
*
60
*
24
;
newDate.setTime(time *
1000
);
SimpleDateFormat format =
new
SimpleDateFormat(
"yyyy-MM-dd"
);
try
{
newDate = format.parse(format.format(newDate));
}
catch
(Exception ex) {
System.out.println(ex.getMessage());
}
return
newDate;
}
public
static
Date getYesterday(Date date) {
long
time = (date.getTime() /
1000
) -
60
*
60
*
24
;
date.setTime(time *
1000
);
SimpleDateFormat format =
new
SimpleDateFormat(
"yyyy-MM-dd"
);
try
{
date = format.parse(format.format(date));
}
catch
(Exception ex) {
System.out.println(ex.getMessage());
}
return
date;
}
private
static
SimpleDateFormat format =
null
;
@SuppressWarnings
(
"unused"
)
public
static
String getStringNowTime() {
format =
new
SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss"
);
Date date =
new
Date();
String dateStr = dateFormat(date);
return
dateStr;
}
/**
* 指定时间的秒数
* 指定时间零点的秒数加指定天数的秒数
* @param time 时间
* @param range 天
* @return
*/
public
static
long
getSpecifyTimeSec(
long
time,
int
range){
Date date =
new
Date((time*
1000
+(
23
-Calendar.ZONE_OFFSET)*
3600000
)/
86400000
*
86400000
-(
23
-Calendar.ZONE_OFFSET)*
3600000
);
long
zeroTime = date.getTime()/
1000
;
long
specifyTime = range *
24
*
3600
;
return
(zeroTime+specifyTime);
}
/**
* 将int型时间(1970年至今的秒数)转换成指定格式的时间
*
* @param unixTime 1970年至今的秒数
* @param dateFormat 时间格式
* @return
* @author sky
*/
public
static
String formatDateByUnixTime(
long
unixTime, String dateFormat){
return
dateFormat(
new
Date(unixTime*
1000
), dateFormat);
}
}
相关推荐
总之,Java中的封装是提高代码质量的重要手段。通过封装,我们可以将复杂的功能分解为简单的模块,降低代码的耦合度,使代码更易于理解和维护。在项目实践中,不断积累并复用这些封装好的类和方法,能够显著提升开发...
常见的加密算法如AES、DES、RSA等可以在Java中实现,用于数据加密和解密。 6. **时间类**:Java 8引入了新的日期和时间API(java.time包),它提供了更直观、更易于使用的日期、时间、时区处理功能,替代了之前的...
1. **DateUtil**: Java中的日期时间处理在早期版本中较为复杂,`DateUtil` 类通常是为了封装`java.util.Date`、`Calendar` 和 `java.time` 包中的类,提供方便的日期时间操作。例如,获取当前日期、格式化日期字符串...
本文将基于标题“Java中对日期的常用处理(转)”来深入探讨Java中的日期处理,结合`DateUtil.java`这个文件名,我们可以推测这是一个包含日期处理工具类的源代码文件。 首先,Java中处理日期的最基础类是`java....
2. **日期时间工具类(DateUtil)**:在Java中,日期和时间操作往往比较复杂,这类工具类会提供方便的方法来解析、格式化日期,进行日期的加减操作等。例如`parse()`用于将字符串转换为日期对象,`format()`则可将日期...
通过这两个实验,学生不仅能够掌握Java中常用类库的使用,还能够提高解决问题的能力,学会如何利用Java标准库来简化编程任务,提高代码的效率和可读性。此外,实验中的方法覆盖练习也有助于学生深入理解面向对象编程...
总结起来,"国外Java Script经典封装"涵盖了JavaScript开发中常用和重要的库和工具,它们是现代Web开发不可或缺的一部分。通过学习和掌握这些资源,开发者能够提高工作效率,创建出功能丰富、用户体验优良的Web应用...
JUnit是Java中广泛使用的单元测试框架,它提供了断言、测试套件等功能,帮助开发者编写可测试的代码。 总之,Java工具类是提高开发效率的关键,它们封装了常见的操作,减少了代码重复,提高了代码可读性和维护性。...
本文将深入探讨Java中常用的日期工具类,并通过示例代码`DateUtil.java`来进一步解释。 1. **`java.util.Date`**: `java.util.Date`是Java最早提供的日期类,它代表了从1970年1月1日00:00:00 GMT到当前时间的毫秒...
JAVA中常用类的常用方法主要涵盖了java语言中基础类库的关键类以及它们提供的主要方法。以下是针对文档内容的详细解释: 1. java.lang.Object类 Object类是Java中所有类的超类,它提供了多种方法,这些方法在Java中...
1. **日期格式化**:在Java中,日期的默认格式可能不满足所有需求。`DateUtil`和`VeDate`可能包含了一系列方法,如`formatDate()`或`toString()`,用于将日期对象转换成特定格式的字符串,例如"yyyy-MM-dd HH:mm:ss...
"android 常用工具封装"这个主题聚焦于如何通过Java语言来优化和整理Android开发中的常用功能,使得开发者能够更方便地集成和调用。下面我们将深入探讨这个主题,以及在压缩包中的"RxTool"可能包含的内容。 首先,...
在这个“Java8应用封装,手写ORM,LOG,framework”的项目中,开发者显然专注于利用Java8的新特性来构建自己的轻量级框架,包括对象关系映射(ORM)、日志系统(LOG)以及一些通用的工具类和自动化配置。 1. **Java...
通过上述分析,我们可以看到,使用Java处理Oracle数据库的复杂查询结果时,不仅需要熟悉SQL语法,还需要掌握如何在Java中构建灵活的数据结构来适应各种查询结果。这种能力对于提高软件开发效率和质量非常重要。希望...
java 常用工具源码,多年工作积累,源码分享。...工作中多年积累常用工具,log封装,日期类,多线程操作,字符串处理,邮件发送,http工具类,页面处理,汉字拼音,ftp ,md5, secret,ValidatorStringEx,Xml类。
Java中常用API主要包括: 1. String类 - 判断方法:如equals()用于比较两个字符串是否相等,equalsIgnoreCase()用于不区分大小写比较字符串等。 - 获取方法:如length()获取字符串长度,charAt()获取指定索引字符...
它是Java中最常用的访问修饰符之一。 - **static**:表示某个属性或方法属于类本身,而不是类的实例。静态方法或变量可以在没有创建对象的情况下直接通过类名调用。 - **void**:用于声明一个方法不返回任何值。例如...
在Java中,日期对象主要由`java.util.Date`类表示,而日期格式化则依赖于`java.text.SimpleDateFormat`类。`SimpleDateFormat`允许我们定义自定义的日期和时间模式,以便根据需要将日期转换为字符串或将字符串解析为...
2. **处理日期Bean**(java处理日期bean.txt):在Java中,日期和时间的处理通常使用`java.util.Date`,`java.time`包(自Java 8引入)以及`java.text.SimpleDateFormat`等类。Bean是一种遵循特定规则的对象,用于...