public class DateUtils { public static final String SIMPLE_DATE_FORMAT = "MM月dd日"; public static final String DEFAULT_DATE_FORMAT = "yyyy-MM-dd"; public static final String DEFAULT_DATETIME_FORMAT1 = "yyyy-MM-dd HH:mm:ss"; public static final String DEFAULT_DATETIME_FORMAT2 = "yyyy-MM-dd HH:mm"; public static final String DEFAULT_DATETIME_FORMAT3 = "yyyy/MM/dd HH:mm:ss"; public static final String DEFAULT_DATETIME_FORMAT4 = "yyyy-MM-dd HH24:mm:ss"; public static final String DEFAULT_DATETIME_FORMAT5 = "yyyy-MM-dd HH24:mm"; public static final String DEFAULT_DATETIME_FORMAT6 = "YYYY-MM-DD:HH24:MI:SS"; public static final String DEFAULT_DATETIME_FORMAT7 = "yyyy/MM/dd"; public static final String DEFAULT_TIME_FORMAT = "HH:mm:ss"; public static final String OTHER_TIME_FORMAT = "HH:mm"; private static final long HOURS_PER_DAY = 24L; private static final long MINUTES_PER_HOUR = 60L; private static final long SECONDS_PER_MINUTE = 60L; private static final long MILLIONSECONDS_PER_SECOND = 1000L; private static final long MILLIONSECONDS_PER_MINUTE = 60000L; private static final long MILLIONSECONDS_SECOND_PER_DAY = 86400000L; public static TimeZone TIMEZONE_UTC = TimeZone.getTimeZone("UTC"); private static final SimpleDateFormat sdfYear = new SimpleDateFormat("yyyy"); private static final SimpleDateFormat sdfDay = new SimpleDateFormat("yyyy-MM-dd"); private static final SimpleDateFormat sdfDays = new SimpleDateFormat("yyyyMMdd"); private static final SimpleDateFormat sdfTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); private DateUtils() { } public static Date getDate(String date) { return getDate(date, "yyyy-MM-dd", (Date)null); } public static Date getMaxDate() { return getDate("9999-12-31", "yyyy-MM-dd", (Date)null); } public static Date getDateTime(String date) { if (StringUtils.isNotBlank(date)) { date = date.replaceAll("/", "-"); return getDate(date, "yyyy-MM-dd HH:mm:ss", (Date)null); } else { return null; } } public static long getDateMilles(Date date, String format) { String formateDate = (new SimpleDateFormat(format)).format(date); try { return (new SimpleDateFormat(format)).parse(formateDate).getTime(); } catch (ParseException var4) { var4.printStackTrace(); return 0L; } } public static Date getDate(String date, String format) { return getDate(date, format, (Date)null); } public static Date getDate(String date, String format, Date defVal) { Date d; try { d = (new SimpleDateFormat(format)).parse(date); } catch (ParseException var5) { d = defVal; } return d; } public static String formatDate(Date date) { return formatDate(date, "yyyy-MM-dd", (String)null); } public static String forDatetime(Date date) { return date != null ? formatDate(date, "yyyy-MM-dd HH:mm:ss", (String)null) : null; } public static String formatTime(Date date) { return formatDate(date, "HH:mm:ss", (String)null); } public static String formatTime(Date date, String format) { return formatDate(date, format, (String)null); } public static String formatDate(Date date, String format) { return formatDate(date, format, (String)null); } public static String formatDateTimeZone(Date date, String format, TimeZone timeZone) { String ret = null; try { SimpleDateFormat sdf = new SimpleDateFormat(format); sdf.setTimeZone(timeZone); ret = sdf.format(date); } catch (Exception var5) { var5.printStackTrace(); } return ret; } public static String formatDate(Date date, String format, String defVal) { String ret; try { ret = (new SimpleDateFormat(format)).format(date); } catch (Exception var5) { ret = defVal; } return ret; } public static Date plusDays(Date date, int days) { if (date == null) { date = getToday(); } return changeDays(date, days); } public static Date plusHours(Date date, int hours) { if (date == null) { date = getToday(); } return changeHours(date, hours); } public static Date plusMinute(Date date, int minutes) { if (date == null) { date = getToday(); } return changeMinute(date, minutes); } public static Date plusMonth(Date date, int months) { if (date == null) { date = getToday(); } return changeMonth(date, months); } public static Date plusYear(Date date, int years) { if (date == null) { date = getToday(); } return changeYear(date, years); } public static Date getToday() { return new Date(); } public static long currentTimeMillis() { return getToday().getTime(); } public static java.sql.Date getTodaySqlDate() { return new java.sql.Date(getToday().getTime()); } public static String getTodayStr(Date date, String format) { if (date == null) { date = getToday(); } if (StringUtils.isBlank(format)) { format = "yyyy-MM-dd"; } return formatDate(date, format); } public static int intervalDay(Date d1, Date d2) { if (d1 == null) { d1 = getToday(); } long intervalMillSecond = setToDayStartTime(d1).getTime() - setToDayStartTime(d2).getTime(); return (int)(intervalMillSecond / 86400000L); } public static int intervalMinutes(Date date1, Date date2) { long intervalMillSecond = date1.getTime() - date2.getTime(); return (int)(intervalMillSecond / 60000L + (long)(intervalMillSecond % 60000L > 0L ? 1 : 0)); } public static int intervalSeconds(Date date1, Date date2) { long intervalMillSecond = date1.getTime() - date2.getTime(); return (int)(intervalMillSecond / 1000L + (long)(intervalMillSecond % 1000L > 0L ? 1 : 0)); } public static Date setToDayStartTime(Date date) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(date.getTime()); calendar.set(11, 0); calendar.set(12, 0); calendar.set(13, 0); calendar.set(14, 0); return calendar.getTime(); } public static Date setToDayEndTime(Date date) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(date.getTime()); calendar.set(11, 23); calendar.set(12, 59); calendar.set(13, 59); calendar.set(14, 0); return calendar.getTime(); } public static String getDateStatus() { Calendar cal = Calendar.getInstance(); int hour = cal.get(11); if (hour >= 6 && hour < 12) { return "morning"; } else if (hour >= 12 && hour < 18) { return "noon"; } else { return hour >= 18 && hour < 24 ? "evning" : "midnight"; } } public static int getAge(Date birthday) { Calendar now = Calendar.getInstance(); Calendar birth = Calendar.getInstance(); birth.setTime(birthday); int year = birth.get(1); int age = now.get(1) - year; now.set(1, year); age = now.before(birth) ? age - 1 : age; return age; } public static boolean isSameDate(Date d1, Date d2) { if (d1 != null && d2 != null) { Calendar c1 = Calendar.getInstance(); c1.setTimeInMillis(d1.getTime()); Calendar c2 = Calendar.getInstance(); c2.setTimeInMillis(d2.getTime()); return c1.get(1) == c2.get(1) && c1.get(2) == c2.get(2) && c1.get(5) == c2.get(5); } else { return false; } } public static boolean isContinueDay(Date d1, Date d2) { if (d1 != null && d2 != null) { return intervalDay(d1, d2) == 1; } else { return false; } } public static Date truncDate(Date date) { Calendar c = Calendar.getInstance(); c.setTime(date); c.set(11, 0); c.set(12, 0); c.set(13, 0); return c.getTime(); } public static Date truncDateHour(Date date) { Calendar c = Calendar.getInstance(); c.setTime(date); c.set(12, 0); c.set(13, 0); return c.getTime(); } public static String getCnDecade(Date input) { String day = formatDate(input); String decade = day.replaceAll("01日", "上旬").replaceAll("11日", "中旬").replaceAll("21日", "下旬"); return decade; } public static Date getTodayZero() { Calendar c = Calendar.getInstance(); c.setTime(new Date()); c.set(11, 0); c.set(12, 0); c.set(13, 0); return c.getTime(); } public static Date getTheDayBefore(Date date) { return new Date(date.getTime() - 86400000L); } public static Date[] getTenDayBefore() { Date[] ret = new Date[2]; Calendar c = Calendar.getInstance(); c.setTime(new Date()); c.set(11, 0); c.set(12, 0); c.set(13, 0); int day = c.get(5); if (day < 10) { c.set(5, 1); ret[1] = new Date(c.getTime().getTime()); c.setTime(getTheDayBefore(c.getTime())); c.set(5, 21); ret[0] = new Date(c.getTime().getTime()); } else if (10 < day && day <= 20) { c.set(5, 1); ret[0] = new Date(c.getTime().getTime()); c.set(5, 11); ret[1] = new Date(c.getTime().getTime()); } else { c.set(5, 11); ret[0] = new Date(c.getTime().getTime()); c.set(5, 21); ret[1] = new Date(c.getTime().getTime()); } return ret; } public static Date[] getCurrentTenDay(Date input) { Date[] ret = new Date[2]; Calendar c = Calendar.getInstance(); c.setTime(input); c.set(11, 0); c.set(12, 0); c.set(13, 0); int day = c.get(5); if (day < 10) { c.set(5, 1); ret[0] = new Date(c.getTime().getTime()); c.set(5, 11); ret[1] = new Date(c.getTime().getTime()); } else if (10 < day && day <= 20) { c.set(5, 11); ret[0] = new Date(c.getTime().getTime()); c.set(5, 21); ret[1] = new Date(c.getTime().getTime()); } else { c.set(5, 21); ret[0] = new Date(c.getTime().getTime()); ret[1] = getNextMonthFirst(c.getTime()); } return ret; } public static Date getNextMonthFirst(Date date) { Calendar c = Calendar.getInstance(); c.setTime(date); c.set(11, 0); c.set(12, 0); c.set(13, 0); c.add(2, 1); c.set(5, 1); return c.getTime(); } public static Date[] getTheMonthBefore(Date date) { Date[] ret = new Date[2]; Calendar c = Calendar.getInstance(); c.setTime(date); c.set(11, 0); c.set(12, 0); c.set(13, 0); c.set(5, 1); ret[1] = new Date(c.getTime().getTime()); c.setTime(getTheDayBefore(c.getTime())); c.set(5, 1); ret[0] = new Date(c.getTime().getTime()); return ret; } public static Integer getCurrentQuarter() { int month = Integer.parseInt(formatDate(new Date(), "MM")); int quarter = 0; if (month >= 1 && month <= 3) { quarter = 1; } else if (month >= 4 && month <= 6) { quarter = 2; } else if (month >= 7 && month <= 9) { quarter = 3; } else if (month >= 10 && month <= 12) { quarter = 4; } return Integer.valueOf(quarter); } public static Map<String, String> getQuarterToYearMonthDay(Integer year, Integer quarter) { if (year != null && year.intValue() > 0 && quarter != null && quarter.intValue() > 0) { Map<String, String> map = new HashMap(); if (quarter.intValue() == 1) { map.put("startTime", year + "-01-" + getMonthDays(year, Integer.valueOf(1)) + " 00:00:00"); map.put("endTime", year + "-03-" + getMonthDays(year, Integer.valueOf(3)) + " 23:59:59"); } else if (quarter.intValue() == 2) { map.put("startTime", year + "-04-" + getMonthDays(year, Integer.valueOf(4)) + " 00:00:00"); map.put("endTime", year + "-06-" + getMonthDays(year, Integer.valueOf(6)) + " 23:59:59"); } else if (quarter.intValue() == 3) { map.put("startTime", year + "-07-" + getMonthDays(year, Integer.valueOf(7)) + " 00:00:00"); map.put("endTime", year + "-09-" + getMonthDays(year, Integer.valueOf(9)) + " 23:59:59"); } else if (quarter.intValue() == 4) { map.put("startTime", year + "-10-" + getMonthDays(year, Integer.valueOf(10)) + " 00:00:00"); map.put("endTime", year + "-12-" + getMonthDays(year, Integer.valueOf(12)) + " 23:59:59"); } return map; } else { return null; } } public static Integer getMonthDays(Integer year, Integer month) { if (year != null && year.intValue() > 0 && month != null && month.intValue() > 0) { Calendar c = Calendar.getInstance(); c.set(1, year.intValue()); c.set(2, month.intValue()); c.set(5, 1); c.add(5, -1); return c.get(5); } else { return Integer.valueOf(0); } } public static String getTimeDiffText(Date date1, Date date2) { long diff = Math.abs(date1.getTime() - date2.getTime()) / 1000L; long minuteSeconds = 60L; long hourSeconds = minuteSeconds * 60L; long daySeconds = hourSeconds * 24L; long weekSeconds = daySeconds * 7L; Date min = date1.compareTo(date2) < 0 ? date1 : date2; if (diff >= weekSeconds) { return formatDate(min); } else if (diff >= daySeconds) { return diff / daySeconds + "天前"; } else if (diff >= hourSeconds) { return diff / hourSeconds + "小时前"; } else { return diff >= minuteSeconds ? diff / minuteSeconds + "分钟前" : diff + "秒前"; } } public static int getWeek(Date dt) { int[] week = new int[]{7, 1, 2, 3, 4, 5, 6}; Calendar cal = Calendar.getInstance(); cal.setTime(dt); int w = cal.get(7) - 1; if (w < 0) { w = 0; } return week[w]; } public static Date getCurrentDate(String datePattern) { try { return (new SimpleDateFormat(datePattern)).parse(getCurrentDateByString(datePattern)); } catch (ParseException var2) { var2.printStackTrace(); return null; } } public static String getCurrentDateByString(String datePattern) { return (new SimpleDateFormat(datePattern)).format(System.currentTimeMillis()); } public static String getCurrentDateByString(Date date, String datePattern) { return (new SimpleDateFormat(datePattern)).format(date); } public static boolean beforeDate(Date date1, Date date2) { return date1.before(date2); } public static boolean beforeDate(String date1, String date2) { Date dt1 = null; Date dt2 = null; dt1 = getDateTime(date1); dt2 = getDateTime(date2); return beforeDate(dt1, dt2); } public static boolean betweenDateScope(String date, String from, String end) { if (date != null && from != null && end != null) { return !beforeDate(date, from) && beforeDate(date, end); } else { return false; } } public static boolean checkTimeRange(String time, String startRange, String endRange) { String[] s = startRange.split(":"); int totalStart = Integer.parseInt(s[0]) * 3600 + Integer.parseInt(s[1]) * 60 + Integer.parseInt(s[2]); String[] e = endRange.split(":"); int totalEnd = Integer.parseInt(e[0]) * 3600 + Integer.parseInt(e[1]) * 60 + Integer.parseInt(e[2]); String[] t = time.split(":"); int timeTotal = Integer.parseInt(t[0]) * 3600 + Integer.parseInt(t[1]) * 60 + Integer.parseInt(t[2]); return timeTotal >= totalStart && timeTotal <= totalEnd; } private static Date changeMinute(Date date, int minutes) { Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.add(12, minutes); return cal.getTime(); } private static Date changeHours(Date date, int hours) { Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.add(11, hours); return cal.getTime(); } private static Date changeDays(Date date, int days) { Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.add(6, days); return cal.getTime(); } private static Date changeYear(Date date, int years) { Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.add(1, years); return cal.getTime(); } private static Date changeMonth(Date date, int months) { Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.add(2, months); return cal.getTime(); } public static Date getCurrentDayBegin() { Calendar calendar = new GregorianCalendar(); calendar.set(11, 0); calendar.set(12, 0); calendar.set(13, 0); return calendar.getTime(); } public static Date getCurrentDayEnd() { Calendar calendar = new GregorianCalendar(); calendar.set(11, 23); calendar.set(12, 59); calendar.set(13, 59); return calendar.getTime(); } public static Date getLastDayBegin() { Calendar calendar = new GregorianCalendar(); calendar.set(11, 0); calendar.set(12, 0); calendar.set(13, 0); calendar.add(5, -1); return calendar.getTime(); } public static Date getLastDayEnd() { Calendar calendar = new GregorianCalendar(); calendar.set(11, 23); calendar.set(12, 59); calendar.set(13, 59); calendar.add(5, -1); return calendar.getTime(); } public static Date getBeforeYesterdayBegin() { Calendar calendar = new GregorianCalendar(); calendar.set(11, 0); calendar.set(12, 0); calendar.set(13, 0); calendar.add(5, -2); return calendar.getTime(); } public static Date BeforeYesterdayEnd() { Calendar calendar = new GregorianCalendar(); calendar.set(11, 23); calendar.set(12, 59); calendar.set(13, 59); calendar.add(5, -2); return calendar.getTime(); } public static Date getCurrentMonthFirstDay() { Calendar calendar = Calendar.getInstance(); calendar.add(2, 0); calendar.set(11, 0); calendar.set(12, 0); calendar.set(13, 0); calendar.set(5, 1); return calendar.getTime(); } public static Date getLastMonthDayBegin() { Calendar calendar = new GregorianCalendar(); calendar.set(11, 0); calendar.set(12, 0); calendar.set(13, 0); calendar.add(5, -30); return calendar.getTime(); } public static Date getBeginTime() { Calendar calendar = new GregorianCalendar(); calendar.set(11, 0); calendar.set(12, 0); calendar.set(13, 0); calendar.add(1, -5); return calendar.getTime(); } public static String getYear() { return sdfYear.format(new Date()); } public static String getDay() { return sdfDay.format(new Date()); } public static String getDays() { return sdfDays.format(new Date()); } public static String getTime() { return sdfTime.format(new Date()); } public static boolean compareDate(String s, String e) { if (fomatDate(s) != null && fomatDate(e) != null) { return fomatDate(s).getTime() >= fomatDate(e).getTime(); } else { return false; } } public static boolean compareDate(Date d1, Date d2) { return d1.getTime() >= d2.getTime(); } public static Date fomatDate(String date) { SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd"); try { return fmt.parse(date); } catch (ParseException var3) { var3.printStackTrace(); return null; } } public static boolean isValidDate(String s) { SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd"); try { fmt.parse(s); return true; } catch (Exception var3) { return false; } } public static int getDiffYear(String startTime, String endTime) { SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd"); try { int years = (int)((fmt.parse(endTime).getTime() - fmt.parse(startTime).getTime()) / 86400000L / 365L); return years; } catch (Exception var4) { return 0; } } public static long getDaySub(String beginDateStr, String endDateStr) { long day = 0L; SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); Date beginDate = null; Date endDate = null; try { beginDate = format.parse(beginDateStr); endDate = format.parse(endDateStr); } catch (ParseException var8) { var8.printStackTrace(); } day = (endDate.getTime() - beginDate.getTime()) / 86400000L; return day; } public static String getAfterDayDate(String days) { int daysInt = Integer.parseInt(days); return getAfterDayDate(daysInt); } public static String getAfterDayDate(int daysInt) { Calendar canlendar = Calendar.getInstance(); canlendar.add(5, daysInt); Date date = canlendar.getTime(); SimpleDateFormat sdfd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String dateStr = sdfd.format(date); return dateStr; } public static String getAfterDayWeek(String days) { int daysInt = Integer.parseInt(days); Calendar canlendar = Calendar.getInstance(); canlendar.add(5, daysInt); Date date = canlendar.getTime(); SimpleDateFormat sdf = new SimpleDateFormat("E"); String dateStr = sdf.format(date); return dateStr; } public static String getSearchBeginDate(String date, DateUtils.SearchDateBuff buff) { StringBuilder builder = new StringBuilder(date); builder.append(" ").append(buff.toString()); return builder.toString(); } public static int getCurrentTime() { return (int)(System.currentTimeMillis() / 1000L); } public static String getSpecifiedDayBefore(String specifiedDay, String format, String defaultStr) { Calendar c = Calendar.getInstance(); Date date = null; String dayBefore = ""; try { date = (new SimpleDateFormat(format)).parse(specifiedDay); c.setTime(date); int day = c.get(5); c.set(5, day - 1); dayBefore = (new SimpleDateFormat(format)).format(c.getTime()); return dayBefore; } catch (Exception var7) { return defaultStr; } } public static enum SearchDateBuff { SEARCH_BEGIN_TIME("00:00:00"), SEARCH_END_TIME("23:59:59"); private String buff; private SearchDateBuff(String buff) { this.buff = buff; } public String toString() { return this.buff; } } }
- 浏览: 23937 次
文章分类
- 全部博客 (22)
- 今天有时间写一个计算两个日期之间有多少个日期 (1)
- java获取当前系统的所有进程列表 (1)
- spirng aop 切面 (1)
- soap wsdl webService (0)
- soap wsdl webService 基础 (1)
- dbcp 数据源 (1)
- svn 导出log的问题 代码统计量 (1)
- java date 比较两个日期的大小 simpladate 日期转换工具类 (1)
- java 日期 date处理 (1)
- springmvc mybatis 的一些感想 (1)
- js 前端 javascript (1)
- MyEclipse中点击Deploy MyEclipse J2EE Project to Server无响应解决方法 (1)
- jquery ajax 异步 (1)
- @ResponseBody 的注解应用 (1)
- Mybatis 调用存储过程 statementType要设置为"CALLABLE" (0)
- .. UserService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} at org (1)
- 随机验证码 前台登录 (1)
- java 读写word java 动态写入 模板文件 (1)
- js函数 汇总大全 非空 非数字 电话号码 身份证 等验证 (1)
- 多个字段 按要求的字段排序 (1)
- 系统间消息通信 socket (1)
- java 开发中常用日期工具类 (1)
- java 线程卡死 (0)
最新评论
-
xianbin:
ironlee 写道为什么不用joda是的。参考:http:/ ...
java 开发中常用日期工具类 -
ironlee:
为什么不用joda
java 开发中常用日期工具类
评论
2 楼
xianbin
2018-01-11
ironlee 写道
为什么不用joda
是的。参考:http://www.joda.org/joda-time/
1 楼
ironlee
2018-01-10
为什么不用joda
相关推荐
在Java编程中,工具类(Utility Classes)是非常重要的组成部分,它们提供了许多通用的功能,以简化开发人员的工作。以下是对"一些java常用的工具类"的详细说明。 首先,工具类通常包含静态方法,这些方法不依赖于...
本文将详细解析"java开发常用工具类"中的关键知识点,包括日历、时间处理、Excel导出、网络请求、流操作、数据处理、数值计算以及XML和Web工具类。 1. **日历和时间处理**: Java中`java.util.Calendar`和`java....
本文将详细解析“java开发常用工具类大全”中涉及的关键知识点,包括但不限于输入字符校验、数据转换、网络操作、加密解密、JSON处理、图像操作以及数据库操作。 1. **输入字符校验类**: 这类工具通常包含对字符...
"java常用开发工具类大全"很可能包含以上提到的一些工具类的实现或扩展,便于开发者在项目中快速集成和使用。通过阅读`readme.htm`和解压后的`1845027886334976.zip`文件,你可以获取更多具体的信息和示例,以便更好...
下面我们将深入探讨一些Java开发中常用的工具类,并了解它们在实际项目中的应用。 1. **`java.util.ArrayList` 和 `java.util.LinkedList`**: 这两个类都是`java.util.List`接口的实现,提供了动态数组和链表数据...
下面我们将详细探讨Java中28个常用的工具类,主要涉及`IO`相关的开发工具。 1. **java.lang.Math**:这个类提供了许多基础数学函数,如求平方根、最大值、最小值、随机数生成等。 2. **java.util.Arrays**:用于...
字符串工具类/数据类型转换类/集合工具类/数组工具类/Properties文件操作类/常用流操作工具类/编码工具类/Json工具类/日期工具类/下载文件工具类/解压ZIP工具类/文件编码转码
在Java开发中,工具类是程序员经常会用到的代码模块,它们封装了各种常见的操作,提高了代码的可重用性和可维护性。以下是对标题和描述中提到的几个常用工具类的详细说明: 1. **DateUtils**: `java.util.Date` 和 ...
"java开发常用工具类.zip" 包含了一系列这样的工具类,这些类可以帮助开发者节省时间,提高代码的可读性和可维护性。下面将详细讨论这个压缩包中可能包含的一些关键工具类和相关知识点。 1. **日期操作工具类**: ...
"Java常用工具类包"是一个集合,它包含了多种针对不同场景的工具类,如文件操作、文本处理、对象转换等。下面将详细介绍这些工具类的主要功能及其应用场景。 1. **文件对比**: - Java中的`java.io.File`类可以...
"java常用工具类"这个主题涵盖了Java开发中常用的类和方法,这些工具类可以帮助我们简化编程工作,提高代码的可读性和可维护性。在Java中,`java.util`包就是这样一个包含大量工具类的包,提供了很多实用的功能。 1...
Java常用工具类是Java开发中不可或缺的一部分,它们提供了一系列便捷的方法,帮助开发者高效地处理各种常见任务。在Java中,最著名的工具类库是`java.util`包,它包含了大量实用类,如集合、日期时间、数学计算、...
提供了很丰富的java工具类,包括字符串、数字、日期、文件、图像、编码解码、校验工具、文档操作等。 主要分为以下几种: - 1.通用操作类,例如String、数字、日期、各种校验等 - 2.文档操作,excel、pdf等 - 3.加密...
以上就是Java开发过程中常用的工具类的一些介绍,熟练掌握这些工具类的使用,将极大地提升我们的开发效率和代码质量。在实际项目中,我们还可以根据需要自定义工具类,封装常用的功能,形成自己的代码库。
本文将重点讲解Java日期的常用操作方法,主要基于提供的`JavaDateUtil.java`文件,假设这是一个自定义的日期工具类。 首先,我们来了解`java.util.Date`。这个类在早期的Java版本中被广泛使用,但它的API设计并不...
"java开发中常用的通用工具类.rar"这个压缩包很可能包含了多个用于不同场景的工具类集合,如字符串处理、日期时间操作、集合操作等。下面将对这些常见的Java工具类及其常用方法进行详细说明。 1. **Apache Commons ...
这些工具类和API是Java开发中不可或缺的部分,掌握它们能显著提高开发效率并确保代码的健壮性。在实际项目中,开发者往往需要根据具体需求选择合适的工具类进行组合使用,以实现特定功能。通过深入理解并熟练运用...