package com.zhang.util;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
import org.apache.commons.lang.time.DurationFormatUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* 日期工具类
* getMonthSpace
* @author chj DateUtil.java 2013-12-11
*/
public class DateUtils {
private static Logger log = LoggerFactory.getLogger(DateUtils.class);
public static String DEFAULT_FORMAT = "yyyy-MM-dd";
public static String FORMAT_STR1 = "yyyy.MM.dd";
private static String timePattern = "HH:mm";
public static String timePattern2 = "yyyyMMddHHmmss";
public static String dateTimePattern = "yyyy-MM-dd HH:mm:ss";
/**
* 根据日期格式,返回日期按DEFAULT_FORMAT格式转换后的字符串
*
* @param aDate
* 日期对象
* @return 格式化后的日期的页面显示字符串
*/
public static final String getDate(Date aDate) {
SimpleDateFormat df = null;
String returnValue = "";
if (aDate != null) {
df = new SimpleDateFormat(DEFAULT_FORMAT);
returnValue = df.format(aDate);
}
return (returnValue);
}
public static final String parseToDateTimeStr(Date aDate) {
SimpleDateFormat df = null;
String returnValue = "";
if (aDate != null) {
df = new SimpleDateFormat(dateTimePattern);
returnValue = df.format(aDate);
}
return (returnValue);
}
/**
* 计算两个日期之间相差的天数
*
* @param smdate
* 较小的时间
* @param bdate
* 较大的时间
* @return 相差天数
* @throws ParseException
*/
public static int daysBetween(Date smdate, Date bdate){
try {
SimpleDateFormat sdf = new SimpleDateFormat(DEFAULT_FORMAT);
smdate = sdf.parse(sdf.format(smdate));
bdate = sdf.parse(sdf.format(bdate));
Calendar cal = Calendar.getInstance();
cal.setTime(smdate);
long time1 = cal.getTimeInMillis(); // smdate
cal.setTime(bdate);
long time2 = cal.getTimeInMillis(); // bdate
long between_days = (time2 - time1) / (1000 * 3600 * 24);
return Integer.parseInt(String.valueOf(between_days));
} catch (ParseException e) {
throw new RuntimeException("daysBetween error"+smdate+";"+bdate,e);
}
}
/**
* 计算两个日期之间相差的月数
*
* @param smdate
* 较小的时间
* @param bdate
* 较大的时间
* @return 相差月数
* @throws ParseException
*/
public static int getMonthSpace(Date smdate, Date bdate)
throws ParseException {
return Integer.parseInt(DurationFormatUtils.formatPeriod(smdate.getTime(), bdate.getTime(), "M"));
}
public static int getMonth(Date smdate, Date bdate) throws ParseException {
int result = 0;
Calendar c1 = Calendar.getInstance();
Calendar c2 = Calendar.getInstance();
c1.setTime(smdate);
c2.setTime(bdate);
result = c2.get(Calendar.DAY_OF_MONTH) - c1.get(Calendar.DAY_OF_MONTH);
return result == 0 ? 1 : Math.abs(result);
}
/**
* 按照日期格式,将字符串解析为日期对象
*
* @param aMask
* 输入字符串的格式
* @param strDate
* 一个按aMask格式排列的日期的字符串描述
* @return Date 对象
* @see java.text.SimpleDateFormat
* @throws ParseException
*/
public static final Date convertStringToDate(String aMask, String strDate)
throws ParseException {
SimpleDateFormat df = null;
Date date = null;
df = new SimpleDateFormat(aMask);
if (log.isDebugEnabled()) {
log.debug("converting '" + strDate + "' to date with mask '"
+ aMask + "'");
}
try {
date = df.parse(strDate);
} catch (ParseException pe) {
// log.error("ParseException: " + pe);
throw new ParseException(pe.getMessage(), pe.getErrorOffset());
}
return (date);
}
/**
* This method returns the current date time in the format: yyyy/MM/dd HH:MM
* a
*
* @param theTime
* the current time
* @return the current date/time
*/
public static String getTimeNow(Date theTime) {
return getDateTime(timePattern, theTime);
}
/**
* This method returns the current date in the format: yyyy-MM-dd
*
* @return the current date
* @throws ParseException
*/
public static Calendar getToday() throws ParseException {
Date today = new Date();
SimpleDateFormat df = new SimpleDateFormat(DEFAULT_FORMAT);
// This seems like quite a hack (date -> string -> date),
// but it works ;-)
String todayAsString = df.format(today);
Calendar cal = new GregorianCalendar();
cal.setTime(convertStringToDate(todayAsString));
return cal;
}
/**
* This method generates a string representation of a date's date/time in
* the format you specify on input
*
* @param aMask
* the date pattern the string is in
* @param aDate
* a date object
* @return a formatted string representation of the date
*
* @see java.text.SimpleDateFormat
*/
public static final String getDateTime(String aMask, Date aDate) {
SimpleDateFormat df = null;
String returnValue = "";
if (aDate == null) {
log.error("aDate is null!");
} else {
df = new SimpleDateFormat(aMask);
returnValue = df.format(aDate);
}
return (returnValue);
}
/**
* 根据日期格式,返回日期按DEFAULT_FORMAT格式转换后的字符串
*
* @param aDate
* @return
*/
public static final String convertDateToString(Date aDate) {
return getDateTime(DEFAULT_FORMAT, aDate);
}
/**
* 按照日期格式,将字符串解析为日期对象
*
* @param strDate
* (格式 yyyy-MM-dd)
* @return
*
* @throws ParseException
*/
public static Date convertStringToDate(String strDate)
throws ParseException {
Date aDate = null;
try {
if (log.isDebugEnabled()) {
log.debug("converting date with pattern: " + DEFAULT_FORMAT);
}
aDate = convertStringToDate(DEFAULT_FORMAT, strDate);
} catch (ParseException pe) {
log.error("Could not convert '" + strDate
+ "' to a date, throwing exception");
throw new ParseException(pe.getMessage(), pe.getErrorOffset());
}
return aDate;
}
/**
* 时间相加
*
* @param date
* @param day
* @return
*/
public static Date addDay(Date date, int day) {
GregorianCalendar calendar = new GregorianCalendar();
calendar.setTime(date);
calendar.add(Calendar.DAY_OF_YEAR, day);
return calendar.getTime();
}
public static Date addHour(Date date, int hour) {
GregorianCalendar calendar = new GregorianCalendar();
calendar.setTime(date);
calendar.add(Calendar.HOUR, hour);
return calendar.getTime();
}
/**
* 月相加
*
* @param date
* @param month
* @return
*/
public static Date addMonth(Date date, int month) {
GregorianCalendar calendar = new GregorianCalendar();
calendar.setTime(date);
calendar.add(Calendar.MONTH, month);
return calendar.getTime();
}
public static int getDay(Date d) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(d);
return calendar.get(Calendar.DATE);
}
/**
* 格式化日期
*
* @param date
* 日期对象
* @return String 日期字符串
*/
/**
* 本年的第一天
*/
public static String getYearFirst(Integer year) {
return formatDate(getCurrYearFirst(year));
}
/**
* 本年的最后一天
*
* @author cjx 2013-2-25 DateUtil String
* @param year
* @return
*
* getYearLast
*/
public static String getYearLast(Integer year) {
return formatDate(getCurrYearLast(year));
}
public static Integer getYear() {
Date date = new Date();
SimpleDateFormat f = new SimpleDateFormat("yyyy");
String year = f.format(date);
return Integer.valueOf(year);
}
/**
*
* return yyyy-MM-dd
*
* @param date
* @return
*/
public static String formatDate(Date date) {
SimpleDateFormat f = new SimpleDateFormat(DEFAULT_
没有合适的资源?快使用搜索试试~ 我知道了~
基于ssm+mysql实现的图书在线管理系统源码.zip
共312个文件
jar:98个
gif:47个
class:30个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 97 浏览量
2023-10-15
13:57:23
上传
评论
收藏 36.48MB ZIP 举报
温馨提示
基于ssm+mysql实现的图书在线管理系统源码 基于ssm+mysql实现的图书在线管理系统源码 基于ssm+mysql实现的图书在线管理系统源码 基于ssm+mysql实现的图书在线管理系统源码 基于ssm+mysql实现的图书在线管理系统源码 基于ssm+mysql实现的图书在线管理系统源码 基于ssm+mysql实现的图书在线管理系统源码 基于ssm+mysql实现的图书在线管理系统源码基于ssm+mysql实现的图书在线管理系统源码基于ssm+mysql实现的图书在线管理系统源码 基于ssm+mysql实现的图书在线管理系统源码 基于ssm+mysql实现的图书在线管理系统源码 基于ssm+mysql实现的图书在线管理系统源码 基于ssm+mysql实现的图书在线管理系统源码 基于ssm+mysql实现的图书在线管理系统源码 基于ssm+mysql实现的图书在线管理系统源码 基于ssm+mysql实现的图书在线管理系统源码
资源推荐
资源详情
资源评论
收起资源包目录
基于ssm+mysql实现的图书在线管理系统源码.zip (312个子文件)
DateUtils.class 10KB
UserController.class 9KB
BookController.class 8KB
SpringUtils.class 7KB
RecordController.class 6KB
BaseController.class 3KB
Record.class 3KB
Book.class 3KB
UsersListener.class 2KB
UserServiceImpl.class 2KB
User.class 2KB
TestRecord.class 2KB
PageUtil.class 2KB
BookServiceImpl.class 2KB
LoginInterceptor.class 2KB
ServiceResult.class 2KB
TestLogin.class 2KB
RecordServiceImpl.class 2KB
TestMybatis.class 2KB
DateJsonValueProcessor.class 1KB
JsonResult.class 1KB
IndexController.class 899B
UserService.class 863B
UserDao.class 851B
BaseEntity.class 783B
BookService.class 664B
BookDao.class 652B
RecordService.class 543B
RecordDao.class 531B
Constants.class 431B
.classpath 10KB
org.eclipse.wst.common.component 670B
org.eclipse.wst.jsdt.ui.superType.container 49B
bootstrap.css 143KB
bootstrap.min.css 118KB
bootstrap-theme.css 26KB
bootstrap-theme.min.css 23KB
style.css 11KB
style.css 8KB
Thumbs.db 108KB
glyphicons-halflings-regular.eot 20KB
prod1.gif 13KB
prod2.gif 13KB
footer_bg.gif 12KB
about.gif 10KB
center_bg.gif 8KB
thumb3.gif 6KB
thumb2.gif 6KB
thumb1.gif 5KB
loading.gif 3KB
border.gif 2KB
logo.gif 2KB
special_icon.gif 2KB
new_icon.gif 2KB
order_now.gif 2KB
promo_icon.gif 2KB
zoom.gif 2KB
cart_thumb.gif 2KB
csscreme.gif 2KB
new_prod_box.gif 1KB
prevlabel.gif 1KB
nextlabel.gif 1KB
bullet4.gif 1KB
bullet5.gif 1KB
bullet3.gif 1KB
bullet1.gif 1KB
bullet2.gif 1KB
bullet6.gif 1KB
closelabel.gif 979B
footer_logo.gif 723B
banner.gif 595B
register_bt.gif 556B
contact_bt.gif 487B
gb.gif 382B
fr.gif 366B
de.gif 362B
prev.gif 307B
next.gif 305B
left_menu_bullet.gif 281B
box_bottom.gif 262B
box_top.gif 262B
cart.gif 260B
close.gif 222B
box_center.gif 93B
color3.gif 55B
color2.gif 55B
color1.gif 55B
blank.gif 43B
aspectjweaver.jar 1.8MB
druid-1.0.2.jar 1.74MB
com.springsource.org.aspectj.weaver-1.6.8.RELEASE.jar 1.57MB
ehcache-core-2.6.8.jar 1.28MB
jsf-impl.jar 1.19MB
javaee.jar 1.09MB
spring-context-4.1.2.RELEASE.jar 1003KB
spring-core-4.1.2.RELEASE.jar 982KB
spring-context-4.0.6.RELEASE.jar 955KB
spring-core-4.0.6.RELEASE.jar 954KB
jackson-databind-2.1.5.jar 906KB
freemarker-2.3.13.jar 850KB
共 312 条
- 1
- 2
- 3
- 4
资源评论
辣椒种子
- 粉丝: 3315
- 资源: 5724
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Q1.py
- 企业政府灵智电子政务网站系统-lingzhi.rar
- Thinkphp内核开发Lsky Pro兰空图床网站源码.rar
- 基于FPGA(XC6SLX9)+SDRAM+AD7829多通道数据采集板硬件(原理图+PCB)工程文件.zip
- 阿里巴巴精准测试体系:基于代码链路分析的性能优化方案
- mmexport1714217773503.jpg
- 【图片网盘外链系统5.0】全新前端UI界面设计 支持图片违规检测网站自适应H5源码.rar
- jsp+sql的BBS论坛系统.zip
- 网盘外链PHP开发彩虹网盘外链程序源码.rar
- 2023年最新文件快递柜系统网站源码 保护用户隐私的匿名口令分享和临时文件分享功能.rar
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功