package com.util;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
/**
* 时间操作器
* @author Alien
*
*/
public class TimeFormator {
//dat格式为:"1900-02-21 12:23:33";
public Date fromStrToDate(String dat){
SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = null;
try {
date = dateformat .parse(dat);
} catch (ParseException e) {
e.printStackTrace();
}
return date;
}
//dat格式为:"1900-02-2";
public Date fromToDate(String dat){
SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd");
Date date = null;
try {
date = dateformat .parse(dat);
} catch (ParseException e) {
e.printStackTrace();
}
return date;
}
/**
* 获取今天时间 格式yyyy-MM-dd
* @return
*/
public String getToday(){
String str = "";
SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd");
str = dateformat.format(new Date());
return str;
}
/**
* 获取现在时间 格式: yy-mm-dd HH:mm:ss
* @return
*/
public static String getNow(){
String str = "";
SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
str = dateformat.format(new Date());
return str;
}
/**
* 获取现在时间 格式: yy-mm-dd HH:mm:ss
* @return TIMESTAMP
*/
public static Timestamp getNowTimestamp(){
String str = "";
SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
str = dateformat.format(new Date());
return fromStringToTimestamp(str);
}
/**
* 获取现在的时间 格式:xx年xx月xx日 xx:xx:ss
* @return
*/
public String getNowWithChin(){
Date now = new Date();
DateFormat d6 = DateFormat.getDateTimeInstance(DateFormat.LONG,DateFormat.MEDIUM);
String str6 = d6.format(now);
return str6;
}
/**
* String 转化为 timestamp
* @param time
* @return
*/
public static Timestamp fromStringToTimestamp(String time){
Timestamp ts = Timestamp.valueOf(time);
return ts;
}
/**
* 获取间隔今天N天的日期 负数为过去
* @param n
* @return
*/
public String getTheDay(int n) {
SimpleDateFormat myFormatter = new SimpleDateFormat("yyyy-MM-dd");
long day = 0;
long temp = 0;
String days = "";
try {
Date date = new Date();
day = date.getTime();
temp = 24 * 60 * 60 * 1000 * (n);
days = myFormatter.format(day + temp);
} catch (Exception e) {
return "";
}
return days;
}
/**
* 获取间隔今天N天的日期 负数为过去
* @param n
* @return yyyy-MM-dd HH:mm:ss
*/
public String getTheDayFromADay(int n,String time) {
String times= "";
String temp = this.getTheDate(n);
temp = temp + " 23:59:59";
return times;
}
/**
* 得到二个日期间的间隔天数
*/
public static String getTwoDay(String sj1, String sj2) {
SimpleDateFormat myFormatter = new SimpleDateFormat("yyyy-MM-dd");
long day = 0;
try {
java.util.Date date = myFormatter.parse(sj1);
java.util.Date mydate = myFormatter.parse(sj2);
day = (date.getTime() - mydate.getTime()) / (24 * 60 * 60 * 1000);
} catch (Exception e) {
return "";
}
return day + "";
}
//获取当天时间
public String getNowTime(String dateformat){
Date now = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat(dateformat);//可以方便地修改日期格式
String hehe = dateFormat.format(now);
return hehe;
}
/**
* 获取上一月月
* @return
*/
public String getTheDateForMonth(){
Calendar cd = Calendar.getInstance();
int day = cd.get(Calendar.DATE);
int month = cd.get(Calendar.MONTH);
int year = cd.get(Calendar.YEAR);
return year+"-"+month+"-"+day;
}
// 获得当前日期与本周日相差的天数
private int getMondayPlus() {
Calendar cd = Calendar.getInstance();
// 获得今天是一周的第几天,星期日是第一天,星期二是第二天......
int dayOfWeek = cd.get(Calendar.DAY_OF_WEEK)-1; //因为按中国礼拜一作为第一天所以这里减1
if (dayOfWeek == 1) {
return 0;
} else {
return 1 - dayOfWeek;
}
}
//获得下个月最后一天的日期
public String getNextMonthEnd(){
String str = "";
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
Calendar lastDate = Calendar.getInstance();
lastDate.add(Calendar.MONTH,1);//加一个月
lastDate.set(Calendar.DATE, 1);//把日期设置为当月第一天
lastDate.roll(Calendar.DATE, -1);//日期回滚一天,也就是本月最后一天
str=sdf.format(lastDate.getTime());
return str;
}
/**
* 获取长时间计算 返回和今天相差多少天的日期
* @param time
* @param n
* @return yyyy-MM-dd
*/
public String getTheDate(int n){
String str = "";
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
Calendar date = Calendar.getInstance();
date.roll(date.DATE, n);
str = sdf.format(date.getTime());
return str;
}
/**
* 返回和今天相差月数日期
* @param n
* @return
*/
public String getTheMonthDay(int n){
String str = "";
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
Calendar date = Calendar.getInstance();
Date now = date.getTime();
long now1 = now.getTime();
int k =(n/12)+1 ;
date.roll(date.MONTH, n);
if(n>0&&(date.getTime().getTime()<now1))
date.roll(date.YEAR, k);
str = sdf.format(date.getTime());
System.out.println(str);
return str;
}
/**
* 比较时间是否大于今天
* @param time yyyy-MM-dd
* @return
*/
public boolean TimeCompareToday(String time){
SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd");
Calendar c1 = Calendar.getInstance();
Calendar c2 = Calendar.getInstance();
try {
c2.setTime(dateformat.parse(time));
} catch (ParseException e) {
e.printStackTrace();
}
if(c2.after(c1)){
return true;
}
else return false;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
JSP养老保险管理系统
共298个文件
gif:181个
class:33个
png:12个
1星 需积分: 32 30 下载量 87 浏览量
2015-04-21
11:36:13
上传
评论 2
收藏 4.72MB RAR 举报
温馨提示
前台注册、登录、查看管理;后台村镇登录查看费用信息和个人信息;管理员管理村镇信息、考勤信息等,在此基础上实现动态的对单位养老保险进行管理。
资源推荐
资源详情
资源评论
收起资源包目录
JSP养老保险管理系统 (298个子文件)
MessageDigest.class 8KB
usersAction.class 7KB
BaseDaoBean.class 6KB
moneyAction.class 6KB
lqmoneyAction.class 5KB
TimeFormator.class 5KB
noticeAction.class 4KB
usersServiceBean.class 4KB
moneyServiceBean.class 4KB
burgnameAction.class 4KB
lqmoneyServiceBean.class 4KB
noticeServiceBean.class 3KB
burgnameServiceBean.class 3KB
users.class 3KB
adminAction.class 3KB
BaseAction.class 2KB
money.class 2KB
adminServiceBean.class 2KB
lqmoney.class 2KB
LoginInterceptor.class 1KB
notice.class 1KB
PageUtil.class 1KB
admin.class 1KB
BaseDao.class 1KB
ImageUtil.class 1003B
burgname.class 899B
Constant.class 856B
usersService.class 731B
moneyService.class 641B
lqmoneyService.class 627B
noticeService.class 598B
burgnameService.class 584B
adminService.class 174B
.classpath 8KB
org.eclipse.wst.common.component 450B
org.eclipse.wst.jsdt.ui.superType.container 49B
base.css 6KB
content.css 6KB
unicornStyle.css 5KB
admin.css 4KB
unicornlogin.css 4KB
style.css 3KB
common.css 3KB
newmenu.css 2KB
main.css 1KB
tab.css 1KB
menu.css 1005B
drag.css 560B
Thumbs.db 282KB
denglu.gif 72KB
error-2.gif 7KB
logo3.gif 5KB
down.gif 5KB
lefttopp.gif 5KB
nopic.gif 3KB
unicornButton.gif 3KB
menu_top.gif 3KB
pdf.gif 3KB
in.gif 2KB
cursor_hourglas.gif 2KB
ico_spider.gif 2KB
qc.gif 2KB
menubg.gif 2KB
help_ico.gif 2KB
fanhui.gif 2KB
fanxuan.gif 2KB
unicorn_ico_blog.gif 1KB
unicorn_ico_JobSearch.gif 1KB
unicorn_ico_blog36.gif 1KB
globle.gif 1KB
unicorn_login_MenuBG.gif 1KB
001_57.gif 1KB
001_20.gif 1KB
001_44.gif 1KB
001_56.gif 1KB
001_14.gif 1KB
001_30.gif 1KB
001_11.gif 1KB
001_55.gif 1KB
001_54.gif 1KB
unicorn_ico_account.gif 1KB
unicorn_ico_refresh.gif 1KB
book.gif 1KB
brow.gif 1KB
title.gif 1KB
g_page.gif 1024B
005.gif 1024B
unicorn_ico_SystemSetting.gif 1020B
unicorn_ico_resume.gif 1020B
topitembg.gif 1020B
men-11.gif 1019B
unicorn_ico_resume_add.gif 1016B
unicorn_ico_JobRecord.gif 945B
on.gif 907B
s_deleted.gif 905B
dot_process.gif 825B
siyi.gif 815B
unicorn_ico_account_ss.gif 812B
h-.gif 808B
s-.gif 808B
共 298 条
- 1
- 2
- 3
资源评论
- javawang20142015-04-21连个数据库都没有
bysj32
- 粉丝: 2
- 资源: 14
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功