/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package dwz.common.util.time;
import java.text.ParseException;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.TimeZone;
import dwz.common.util.StringUtils;
/**
* 常用日期工具
* <p>A suite of utilities surrounding the use of the
* {@link java.util.Calendar} and {@link java.util.Date} object.</p>
*
* <p>DateUtils contains a lot of common methods considering manipulations
* of Dates or Calendars. Some methods require some extra explanation.
* The truncate, ceiling and round methods could be considered the Math.floor(),
* Math.ceil() or Math.round versions for dates
* This way date-fields will be ignored in bottom-up order.
* As a complement to these methods we've introduced some fragment-methods.
* With these methods the Date-fields will be ignored in top-down order.
* Since a date without a year is not a valid date, you have to decide in what
* kind of date-field you want your result, for instance milliseconds or days.
* </p>
*
*
*
* @author Apache Software Foundation
* @author <a href="mailto:sergek@lokitech.com">Serge Knystautas</a>
* @author Janek Bogucki
* @author <a href="mailto:ggregory@seagullsw.com">Gary Gregory</a>
* @author Phil Steitz
* @author Robert Scholte
* @since 2.0
* @version $Id: DateUtils.java 911986 2010-02-19 21:19:05Z niallp $
*/
public class DateUtils {
/**
* The UTC time zone (often referred to as GMT).
*/
public static final TimeZone UTC_TIME_ZONE = TimeZone.getTimeZone("GMT");
/**
* Number of milliseconds in a standard second.
* @since 2.1
*/
public static final long MILLIS_PER_SECOND = 1000;
/**
* Number of milliseconds in a standard minute.
* @since 2.1
*/
public static final long MILLIS_PER_MINUTE = 60 * MILLIS_PER_SECOND;
/**
* Number of milliseconds in a standard hour.
* @since 2.1
*/
public static final long MILLIS_PER_HOUR = 60 * MILLIS_PER_MINUTE;
/**
* Number of milliseconds in a standard day.
* @since 2.1
*/
public static final long MILLIS_PER_DAY = 24 * MILLIS_PER_HOUR;
/**
* This is half a month, so this represents whether a date is in the top
* or bottom half of the month.
*/
public final static int SEMI_MONTH = 1001;
private static final int[][] fields = {
{Calendar.MILLISECOND},
{Calendar.SECOND},
{Calendar.MINUTE},
{Calendar.HOUR_OF_DAY, Calendar.HOUR},
{Calendar.DATE, Calendar.DAY_OF_MONTH, Calendar.AM_PM
/* Calendar.DAY_OF_YEAR, Calendar.DAY_OF_WEEK, Calendar.DAY_OF_WEEK_IN_MONTH */
},
{Calendar.MONTH, DateUtils.SEMI_MONTH},
{Calendar.YEAR},
{Calendar.ERA}};
/**
* A week range, starting on Sunday.
*/
public final static int RANGE_WEEK_SUNDAY = 1;
/**
* A week range, starting on Monday.
*/
public final static int RANGE_WEEK_MONDAY = 2;
/**
* A week range, starting on the day focused.
*/
public final static int RANGE_WEEK_RELATIVE = 3;
/**
* A week range, centered around the day focused.
*/
public final static int RANGE_WEEK_CENTER = 4;
/**
* A month range, the week starting on Sunday.
*/
public final static int RANGE_MONTH_SUNDAY = 5;
/**
* A month range, the week starting on Monday.
*/
public final static int RANGE_MONTH_MONDAY = 6;
/**
* Constant marker for truncating
*/
private final static int MODIFY_TRUNCATE = 0;
/**
* Constant marker for rounding
*/
private final static int MODIFY_ROUND = 1;
/**
* Constant marker for ceiling
*/
private final static int MODIFY_CEILING= 2;
/**
* <p><code>DateUtils</code> instances should NOT be constructed in
* standard programming. Instead, the class should be used as
* <code>DateUtils.parse(str);</code>.</p>
*
* <p>This constructor is public to permit tools that require a JavaBean
* instance to operate.</p>
*/
public DateUtils() {
super();
}
//-----------------------------------------------------------------------
/**
* <p>Checks if two date objects are on the same day ignoring time.</p>
*
* <p>28 Mar 2002 13:45 and 28 Mar 2002 06:01 would return true.
* 28 Mar 2002 13:45 and 12 Mar 2002 13:45 would return false.
* </p>
*
* @param date1 the first date, not altered, not null
* @param date2 the second date, not altered, not null
* @return true if they represent the same day
* @throws IllegalArgumentException if either date is <code>null</code>
* @since 2.1
*/
public static boolean isSameDay(Date date1, Date date2) {
if (date1 == null || date2 == null) {
throw new IllegalArgumentException("The date must not be null");
}
Calendar cal1 = Calendar.getInstance();
cal1.setTime(date1);
Calendar cal2 = Calendar.getInstance();
cal2.setTime(date2);
return isSameDay(cal1, cal2);
}
/**
* <p>Checks if two calendar objects are on the same day ignoring time.</p>
*
* <p>28 Mar 2002 13:45 and 28 Mar 2002 06:01 would return true.
* 28 Mar 2002 13:45 and 12 Mar 2002 13:45 would return false.
* </p>
*
* @param cal1 the first calendar, not altered, not null
* @param cal2 the second calendar, not altered, not null
* @return true if they represent the same day
* @throws IllegalArgumentException if either calendar is <code>null</code>
* @since 2.1
*/
public static boolean isSameDay(Calendar cal1, Calendar cal2) {
if (cal1 == null || cal2 == null) {
throw new IllegalArgumentException("The date must not be null");
}
return (cal1.get(Calendar.ERA) == cal2.get(Calendar.ERA) &&
cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) &&
cal1.get(Calendar.DAY_OF_YEAR) == cal2.get(Calendar.DAY_OF_YEAR));
}
//-----------------------------------------------------------------------
/**
* <p>Checks if two date objects represent the same instant in time.</p>
*
* <p>This method compares the long millisecond time of the two objects.</p>
*
* @param date1 the first date, not altered, not null
* @param date2 the second date, not altered, not null
* @return true if they represent the same millisecond instant
* @throws IllegalArgumentException if either date is <code>null</code>
* @since 2.1
*/
public static boolean isSameInstant(Date date1, Date date2) {
if (date1 == null || date2 == null) {
throw new IllegalArgumentException("The date must not be null");
没有合适的资源?快使用搜索试试~ 我知道了~
dwz4j-springmvc官方范例
共785个文件
class:210个
png:194个
java:174个
4星 · 超过85%的资源 需积分: 9 150 下载量 144 浏览量
2013-03-18
10:55:54
上传
评论 1
收藏 21.86MB ZIP 举报
温馨提示
dwz与spring集成的例子 DWZ Java (MyBiaits+SpringMVC) 示例 开发环境: 1) 数据库:mysql 请修改 src/jdbc.properties这个文件的数据库连接 创建数据库dwz4j 导入测试数据:doc/dwz4j.sql mysql -u root -p dwz4j < dwz4j.sql 2) JDK 1.6 3) 项目文件UTF-8编码,如果用eclipse打开项目,注意把工作空间编码设成UTF-8 4) 启动tomcat
资源推荐
资源详情
资源评论
收起资源包目录
dwz4j-springmvc官方范例 (785个子文件)
MemcachedClient.class 30KB
SockIOPool.class 25KB
FastDateFormat.class 16KB
MemcacheCacheManager.class 16KB
DateUtils.class 14KB
StringUtils.class 11KB
PropertiesHelper.class 10KB
BookServiceMgrImpl.class 10KB
ReflectionUtils.class 9KB
AppConfiguration.class 9KB
MemcachedClient$NIOLoader.class 8KB
DurationFormatUtils.class 8KB
SockIOPool$SockIO.class 7KB
NativeHandler.class 7KB
FileUtils.class 7KB
OffsetLimitInterceptor.class 7KB
DateUtil.class 6KB
ThreadPool.class 6KB
ResChapter.class 6KB
Queue.class 6KB
CollectionHelper.class 5KB
WebUtils.class 5KB
ReflectUtil.class 5KB
Chapter.class 5KB
ChapterController.class 5KB
TaskParseImpl.class 5KB
AbstractBusinessObjectServiceMgr.class 5KB
TaskUnitImpl.class 4KB
TaskEngine.class 4KB
BaseController.class 4KB
ImageUtil.class 4KB
DateFormatUtils.class 4KB
ResBook.class 4KB
MemcachedClient$NIOLoader$Connection.class 4KB
Logger.class 4KB
EnumUtils.class 4KB
SequenceGenerator.class 4KB
RandomGUID.class 4KB
PageInfo.class 3KB
PagedQuery.class 3KB
ClassFactoryUtil.class 3KB
ByteBufArrayInputStream.class 3KB
MD5Util.class 3KB
ScanClassUtils.class 3KB
StringEncryptUtil.class 3KB
BookController.class 3KB
ExecUtils.class 3KB
Book.class 3KB
PinyinUtil.class 3KB
StopWatch.class 3KB
IndexController.class 3KB
MemcachedClientSocketPoolConfig.class 3KB
PropertiesUtils.class 3KB
LoopRunnable.class 3KB
UserServiceMgrImplTest.class 3KB
FileStoreUtils.class 3KB
EncodeUtils.class 3KB
DefaultTaskFactory.class 3KB
ThreadPool$2.class 3KB
MemberServiceMgrImpl.class 2KB
SqlRemoveUtils.class 2KB
DateConvertUtils.class 2KB
MapAndObject.class 2KB
MapAndObject$FastPropertyUtils.class 2KB
DefaultErrorHandlerImpl.class 2KB
DB2Dialect.class 2KB
SQLServer2005Dialect.class 2KB
CacheManager.class 2KB
AccessLevel.class 2KB
CommonUtils.class 2KB
AppContextInitListener.class 2KB
BaseConditionVO.class 2KB
DurationFormatUtils$Token.class 2KB
FastDateFormat$TimeZoneNameRule.class 2KB
YesNo.class 2KB
FastDateFormat$PaddedNumberField.class 2KB
AbstractBusinessObject.class 2KB
OracleDialect.class 2KB
ResponseHeaderFilter.class 2KB
FileSizeUtils.class 2KB
SQLServerDialect.class 2KB
Position.class 2KB
UserType.class 2KB
ThreadUtils.class 2KB
TaskFactory.class 2KB
EncodingFilter.class 2KB
FileStoreObject.class 2KB
MemberImpl.class 2KB
SpringContextHolder.class 2KB
LogLevel.class 2KB
Gender.class 2KB
SockIOPool$MaintThread.class 2KB
RandomString.class 2KB
CacheUtils.class 2KB
MemcachedClientConfig.class 2KB
TemplateUtil.class 2KB
ConditionVO.class 2KB
TaskPeriod.class 1KB
PageUtil.class 1KB
ThreadPool$1.class 1KB
共 785 条
- 1
- 2
- 3
- 4
- 5
- 6
- 8
zz_work2000
- 粉丝: 45
- 资源: 62
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
前往页