net.sourceforge.jweb.jstl.fn.TimeUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jweb-common Show documentation
Show all versions of jweb-common Show documentation
本项目主要弥补在使用mybatis3+springmvc+jquery easyui快速搭建web应用系统是遇到的框架不足.
主要工作包括:
1,扩展了ApplicationContextAware,通过单例注入spring容器,提供spring容器外的bean获取方法
2,扩展了apache shiro框架,统一了安全结构
3,扩展了mybatis3拦截器,在两个拦截器中自动完成分页注入,实现内存分页。
4,分页设计数据库方言
5,提供了一个easyuigrid的模型
6,提供了java泛型的jstl
7, xml工具包等一些小工具
The newest version!
package net.sourceforge.jweb.jstl.fn;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;
public class TimeUtil {
private TimeUtil() {
}
public static Date now() {
return new Date();
}
public static Date newDate(long mills) {
return new Date(mills);
}
public static long getTime(Date d) {
return d.getTime();
}
public static boolean before(Date d1, Date d2) {
return d1.before(d2);
}
public static boolean after(Date d1, Date d2) {
return d1.after(d2);
}
public static int compareTo(Date d1, Date d2) {
return d1.compareTo(d2);
}
public static Calendar nowCalendar() {
return Calendar.getInstance();
}
public static Calendar nowCalendar(TimeZone zone) {
return Calendar.getInstance(zone);
}
public static Calendar nowCalendar(Locale locale) {
return Calendar.getInstance(locale);
}
public static Calendar nowCalendar(TimeZone zone, Locale locale) {
return Calendar.getInstance(zone, locale);
}
public static Locale[] getAvailableLocales() {
return Calendar.getAvailableLocales();
}
public static Date getTime(Calendar c) {
return c.getTime();
}
public static void setDate(Calendar c, Date d) {
c.setTime(d);
}
public static long getTimeInMillis(Calendar c) {
return c.getTimeInMillis();
}
public static void setTimeInMillis(Calendar c, long mills) {
c.setTimeInMillis(mills);
}
public static int get(Calendar c, int filed) {
return c.get(filed);
}
public static void set(Calendar c, int field, int value) {
c.set(field, value);
}
public static void setMYD(Calendar c, int y, int m, int d) {
c.set(y, m, d);
}
public static void setMYDH24M(Calendar c, int y, int m, int d, int h24, int mo) {
c.set(y, m, d, h24, mo);
}
public static void setMYDH24MS(Calendar c, int y, int m, int d, int h24, int mo, int s) {
c.set(y, m, d, h24, mo, s);
}
public static void clear(Calendar c) {
c.clear();
}
public static void clear(Calendar c, int field) {
c.clear(field);
}
public static boolean isSet(Calendar c, int f) {
return c.isSet(f);
}
public static boolean before(Calendar c, Calendar c2) {
return c.before(c2);
}
public static boolean after(Calendar c, Calendar c2) {
return c.after(c2);
}
public static int compareTo(Calendar c, Calendar c2) {
return c.compareTo(c2);
}
public static String getDisplayName(Calendar c, int field, int style, Locale locale) {
return c.getDisplayName(field, style, locale);
}
public static Map getDisplayNames(Calendar c, int field, int style, Locale locale) {
return c.getDisplayNames(field, style, locale);
}
public static void add(Calendar c, int field, int amount) {
c.add(field, amount);
}
public static void roll(Calendar c, int field, boolean up) {
c.roll(field, up);
}
public static void roll(Calendar c, int field, int amount) {
c.roll(field, amount);
}
public static void setTimeZone(Calendar c, TimeZone value) {
c.setTimeZone(value);
}
public static TimeZone getTimeZone(Calendar c) {
return c.getTimeZone();
}
public static int getFirstDayOfWeek(Calendar c) {
return c.getFirstDayOfWeek();
}
public static int getMinimalDaysInFirstWeek(Calendar c) {
return c.getMinimalDaysInFirstWeek();
}
public static int getMinimum(Calendar c, int field) {
return c.getMinimum(field);
}
public static int getMaximum(Calendar c, int field) {
return c.getMaximum(field);
}
private static final int ONE_DAY_MILLS = 1000 * 60 * 60 * 24;
public static Integer daysBetween(Date d1, Date d2) {
if (d1 == null || d2 == null)
return null;
return (int) ((d2.getTime() - d1.getTime()) / ONE_DAY_MILLS);
}
public static Integer daysToNow(Date d1) {
return daysBetween(new Date(), d1);
}
}