package com.changda.youda.util;
import org.apache.commons.lang3.StringUtils;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* Created by Administrator on 2017/3/10 010.
*/
public class DateKit {
public static final int INTERVAL_DAY = 1;
public static final int INTERVAL_WEEK = 2;
public static final int INTERVAL_MONTH = 3;
public static final int INTERVAL_YEAR = 4;
public static final int INTERVAL_HOUR = 5;
public static final int INTERVAL_MINUTE = 6;
public static final int INTERVAL_SECOND = 7;
public static final Date tempDate = new Date((new Long("-2177481952000")).longValue());
private static List<SimpleDateFormat> dateFormats = new ArrayList(12) {
private static final long serialVersionUID = 2249396579858199535L;
{
this.add(new SimpleDateFormat("yyyy-MM-dd"));
this.add(new SimpleDateFormat("yyyy/MM/dd"));
this.add(new SimpleDateFormat("yyyy.MM.dd"));
this.add(new SimpleDateFormat("yyyy-MM-dd HH:24:mm:ss"));
this.add(new SimpleDateFormat("yyyy/MM/dd HH:24:mm:ss"));
this.add(new SimpleDateFormat("yyyy.MM.dd HH:24:mm:ss"));
this.add(new SimpleDateFormat("M/dd/yyyy"));
this.add(new SimpleDateFormat("dd.M.yyyy"));
this.add(new SimpleDateFormat("M/dd/yyyy hh:mm:ss a"));
this.add(new SimpleDateFormat("dd.M.yyyy hh:mm:ss a"));
this.add(new SimpleDateFormat("dd.MMM.yyyy"));
this.add(new SimpleDateFormat("dd-MMM-yyyy"));
}
};
public DateKit() {
}
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;
}
public static long DaysBetween(Date date1, Date date2) {
if(date2 == null) {
date2 = new Date();
}
long day = (date2.getTime() - date1.getTime()) / 86400000L;
return day;
}
public static boolean compareDate(String date1, String date2) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
try {
Date e = format.parse(date1);
Date d2 = format.parse(date2);
return !e.after(d2);
} catch (ParseException var5) {
var5.printStackTrace();
return false;
}
}
public static Date dateFormat(String date, String dateFormat) {
if(date == null) {
return null;
} else {
SimpleDateFormat format = new SimpleDateFormat(dateFormat);
try {
return format.parse(date);
} catch (Exception ignored) {
}
return null;
}
}
public static Date dateFormat(String date) {
return dateFormat(date, "yyyy-MM-dd HH:mm:ss");
}
public static String dateFormat(Date date, String dateFormat) {
if(date != null) {
SimpleDateFormat format = new SimpleDateFormat(dateFormat);
if(date != null) {
return format.format(date);
}
}
return "";
}
public static String birthdayFormat(Date date) {
if(date != null) {
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 "";
}
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()) / 86400000L;
return day >= 1L;
}
public static Date getYesterday() {
Date date = new Date();
long time = date.getTime() / 1000L - 86400L;
date.setTime(time * 1000L);
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
try {
date = format.parse(format.format(date));
} catch (Exception var5) {
System.out.println(var5.getMessage());
}
return date;
}
public static Date getWeekAgo() {
Date date = new Date();
long time = date.getTime() / 1000L - 604800L;
date.setTime(time * 1000L);
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
try {
date = format.parse(format.format(date));
} catch (Exception var5) {
System.out.println(var5.getMessage());
}
return date;
}
public static String getDaysAgo(int interval) {
Date date = new Date();
long time = date.getTime() / 1000L - (long)(interval * 60 * 60 * 24);
date.setTime(time * 1000L);
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
try {
return format.format(date);
} catch (Exception var6) {
System.out.println(var6.getMessage());
return "";
}
}
public static Date getTomorrow() {
Date date = new Date();
long time = date.getTime() / 1000L + 86400L;
date.setTime(time * 1000L);
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
try {
date = format.parse(format.format(date));
} catch (Exception var5) {
System.out.println(var5.getMessage());
}
return date;
}
public static Date getBeforeDate(String range) {
Calendar today = Calendar.getInstance();
if("week".equalsIgnoreCase(range)) {
today.add(4, -1);
} else if("month".equalsIgnoreCase(range)) {
today.add(2, -1);
} else {
today.clear();
}
return today.getTime();
}
public static Date getThisWeekStartTime() {
Calendar today = Calendar.getInstance();
today.set(7, today.getFirstDayOfWeek());
Calendar weekFirstDay = Calendar.getInstance();
weekFirstDay.clear();
weekFirstDay.set(1, today.get(1));
weekFirstDay.set(2, today.get(2));
weekFirstDay.set(5, today.get(5));
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 var4) {
;
}
return result;
}
public static Date getStartDay(int year, int month) {
Calendar today = Calendar.getInstance();
today.clear();
today.set(1, year);
today.set(2, month - 1);
today.set(5, 1);
return today.getTime();
}
public static List<Integer> getBeforeYearList(int before) {
Calendar today = Calendar.getInstance();
int theYear = today.get(1);
ArrayList list = new ArrayList();
for(int i = before; i >= 0; --i) {
list.add(Integer.valueOf(theYear - i));
}
return list;
}
public static Date dateAdd(int interval, Date date, int n) {
long time = date.getTime() / 1000L;
switch(interval) {
case 1:
time += (long)(n * 86400);
break;
case 2:
time += (long)(n * 604800);
break;
case 3:
time += (long)(n * 2678400);
break;
case 4:
time += (long)(n * 31536000);
break;
case 5:
time += (long)(n * 3600);
没有合适的资源?快使用搜索试试~ 我知道了~
基于框架的Java专题学习网
共1180个文件
png:216个
js:202个
gif:134个
4星 · 超过85%的资源 需积分: 29 21 下载量 91 浏览量
2017-11-27
16:04:32
上传
评论 3
收藏 14.73MB ZIP 举报
温馨提示
基础知识模块提供有关Java工具软件及Java基础语法知识的教学资源。这部分系统归纳总结了本课程基本理论知识及Eclipse软件操作的基本方法、技巧,可供学生自学,可作为学生入门学习教程或基础知识资料库。基础知识模块的每一个知识点只包含一个教学资源文档。教学资源文档由文本、图片和附件组成。 进阶知识模块提供Java高级编程知识的教学资源。此模块中的每一个进阶知识都是一个专题,包含多个教学资源文档。 实例教程模块提供了从简单到复杂的Java实例讲解文档和代码,以知识点为线,采取循序渐进的方式,引导学生对相关知识的掌握。每一个实例教程包含实例题目、实例内容、实例讲解、运行结果和代码附件。 拓展知识模块精选了网络上的相关知识,作为学生额外学习的内容。既可拓宽学生知识面,又可以加速加深学生对本课程的理解,提高他们对专业知识的实际应用能力。 学生作品展示模块,包括学生课程设计、项目实训的优秀作品及大赛作品等。作品展示要求有标题、作者名、内容介绍、效果展示、附件(相关文档、源代码或发布文件)等内容。 相关资源包括相关软件资源、优秀网站和电予书下载等。 在线测试模块,可以有效地检验学生对Java知识的掌握程度。此模块不做强制要求,可每组自己决定怎么做。 系统包含三类用户角色:系统管理员、教师和学生。学生角色拥有阅读、下载所有的资源的权限;教师角色拥有上传资源,管理自己上传资源的权限;系统管理员角色拥有创建教师用户,管理所有资源等权限,系统只有一个系统管理员。学生通过网站注册拥有学生角色权限
资源推荐
资源详情
资源评论
收起资源包目录
基于框架的Java专题学习网 (1180个子文件)
DateKit.class 14KB
KnowledgeController.class 8KB
UserController.class 8KB
ConfigManager.class 7KB
WebTeacherRController.class 6KB
StudentProductController.class 6KB
FileUploadController.class 6KB
FileSystemStorageService.class 5KB
InstanceController.class 5KB
ResourceController.class 5KB
ExtendKnowledgeController.class 5KB
KnowledgePoint.class 5KB
ImageHunter.class 5KB
WebUserController.class 5KB
KnowledgeServiceImpl.class 5KB
StudentProduct.class 5KB
MD5Utils.class 5KB
Instance.class 4KB
KnowledgePointRequest.class 4KB
WebKnowledgeController.class 4KB
StorageManager.class 4KB
Tools.class 4KB
PathFormat.class 4KB
RestResponseBo.class 4KB
StudentProductRequest.class 4KB
InstanceRequest.class 4KB
BinaryUploader.class 4KB
FileManager.class 4KB
ActionEnter.class 4KB
ExtendKnowledge.class 4KB
Resource.class 4KB
ResourceRequest.class 3KB
MultiState.class 3KB
WebStudentProController.class 3KB
ClassifyController.class 3KB
BaseState.class 3KB
UserServiceImpl.class 3KB
User.class 3KB
StudentProductServiceImpl.class 3KB
WebExpandKnowController.class 2KB
Base64Uploader.class 2KB
ExtendKnowledgeServiceImpl.class 2KB
ResourceServiceImpl.class 2KB
Classify.class 2KB
TeachingSource.class 2KB
ClassifyServiceImpl.class 2KB
UEditorController.class 2KB
KnowledgeSearchRequest.class 2KB
InstanceServiceImpl.class 2KB
UserLogin.class 2KB
BaseInterceptor.class 2KB
Uploader.class 2KB
KnowledgeDao.class 2KB
AdminCommons.class 1KB
AppInfo.class 1KB
KnowledgeService.class 1KB
UserDao.class 1KB
AppInfo$1.class 1KB
RandomUtil.class 1KB
WebUserServiceImpl.class 1KB
ActionMap.class 1KB
UserService.class 1KB
FileType.class 1KB
WebMvcConfig.class 1KB
DateKit$1.class 1KB
Encoder.class 1020B
YoudaApplication.class 1008B
BackResponseBo.class 1001B
ActionState.class 990B
ExtendKnowledgeDao.class 989B
StudentProductService.class 966B
StudentProductDao.class 926B
ActionMap$1.class 920B
ClassifyDao.class 873B
ExtendKnowledgeService.class 826B
MIMEType.class 804B
TipException.class 759B
StorageProperties.class 749B
MIMEType$1.class 742B
ResourceDao.class 738B
DruidStatViewServlet.class 729B
Question.class 716B
ResourceService.class 698B
DruidStatFilter.class 648B
UeditorTestApplicationTests.class 633B
StorageFileNotFoundException.class 631B
InstanceDao.class 599B
FileType$1.class 593B
StorageException.class 577B
InstanceService.class 562B
StorageService.class 530B
ClassifyService.class 399B
WebUserService.class 380B
AuthController.class 325B
State.class 281B
mvnw.cmd 5KB
bootstrap.css 144KB
bootstrap.css 144KB
bootstrap.min.css 120KB
bootstrap.min.css 120KB
共 1180 条
- 1
- 2
- 3
- 4
- 5
- 6
- 12
资源评论
- xiaom5502018-11-22学习一下。
bluesmi
- 粉丝: 1
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功