1. import java.sql.Timestamp;
  2. import java.text.ParsePosition;
  3. import java.text.SimpleDateFormat;
  4. import java.util.Calendar;
  5. import java.util.Date;
  6. import java.util.GregorianCalendar;
  7. import java.util.regex.Pattern;
  8. import org.apache.commons.logging.Log;
  9. import org.apache.commons.logging.LogFactory;
  10.  
  11. public class DateUtils {
  12. protected static Log logger = LogFactory.getLog(DateUtils.class);
  13.  
  14. // 格式:年-月-日 小时:分钟:秒
  15. public static final String FORMAT_ONE = "yyyy-MM-dd HH:mm:ss";
  16.  
  17. // 格式:年-月-日 小时:分钟
  18. public static final String FORMAT_TWO = "yyyy-MM-dd HH:mm";
  19.  
  20. // 格式:年月日 小时分钟秒
  21. public static final String FORMAT_THREE = "yyyyMMdd-HHmmss";
  22.  
  23. // 格式:年-月-日
  24. public static final String LONG_DATE_FORMAT = "yyyy-MM-dd";
  25.  
  26. // 格式:月-日
  27. public static final String SHORT_DATE_FORMAT = "MM-dd";
  28.  
  29. // 格式:小时:分钟:秒
  30. public static final String LONG_TIME_FORMAT = "HH:mm:ss";
  31.  
  32. //格式:年-月
  33. public static final String MONTG_DATE_FORMAT = "yyyy-MM";
  34.  
  35. // 年的加减
  36. public static final int SUB_YEAR = Calendar.YEAR;
  37.  
  38. // 月加减
  39. public static final int SUB_MONTH = Calendar.MONTH;
  40.  
  41. // 天的加减
  42. public static final int SUB_DAY = Calendar.DATE;
  43.  
  44. // 小时的加减
  45. public static final int SUB_HOUR = Calendar.HOUR;
  46.  
  47. // 分钟的加减
  48. public static final int SUB_MINUTE = Calendar.MINUTE;
  49.  
  50. // 秒的加减
  51. public static final int SUB_SECOND = Calendar.SECOND;
  52.  
  53. static final String dayNames[] = { "星期日", "星期一", "星期二", "星期三", "星期四","星期五", "星期六" };
  54.  
  55. @SuppressWarnings("unused")
  56. private static final SimpleDateFormat timeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  57.  
  58. public DateUtils() {}
  59.  
  60. /**
  61. * 把符合日期格式的字符串转换为日期类型
  62. *
  63. * @param dateStr
  64. * @return
  65. */
  66. public static java.util.Date stringtoDate(String dateStr, String format) {
  67. Date d = null;
  68. SimpleDateFormat formater = new SimpleDateFormat(format);
  69. try {
  70. formater.setLenient(false);
  71. d = formater.parse(dateStr);
  72. } catch (Exception e) {
  73. // log.error(e);
  74. d = null;
  75. }
  76. return d;
  77. }
  78.  
  79. /**
  80. * 把符合日期格式的字符串转换为日期类型
  81. */
  82. public static java.util.Date stringtoDate(String dateStr, String format,
  83. ParsePosition pos) {
  84. Date d = null;
  85. SimpleDateFormat formater = new SimpleDateFormat(format);
  86. try {
  87. formater.setLenient(false);
  88. d = formater.parse(dateStr, pos);
  89. } catch (Exception e) {
  90. d = null;
  91. }
  92. return d;
  93. }
  94.  
  95. /**
  96. * 把日期转换为字符串
  97. *
  98. * @param date
  99. * @return
  100. */
  101. public static String dateToString(java.util.Date date, String format) {
  102. String result = "";
  103. SimpleDateFormat formater = new SimpleDateFormat(format);
  104. try {
  105. result = formater.format(date);
  106. } catch (Exception e) {
  107. // log.error(e);
  108. }
  109. return result;
  110. }
  111.  
  112. /**
  113. * 获取当前时间的指定格式
  114. *
  115. * @param format
  116. * @return
  117. */
  118. public static String getCurrDate(String format) {
  119. return dateToString(new Date(), format);
  120. }
  121.  
  122. /**
  123. *
  124. * @param dateStr
  125. * @param amount
  126. * @return
  127. */
  128. public static String dateSub(int dateKind, String dateStr, int amount) {
  129. Date date = stringtoDate(dateStr, FORMAT_ONE);
  130. Calendar calendar = Calendar.getInstance();
  131. calendar.setTime(date);
  132. calendar.add(dateKind, amount);
  133. return dateToString(calendar.getTime(), FORMAT_ONE);
  134. }
  135.  
  136. /**
  137. * 两个日期相减
  138. *
  139. * @param firstTime
  140. * @param secTime
  141. * @return 相减得到的秒数
  142. */
  143. public static long timeSub(String firstTime, String secTime) {
  144. long first = stringtoDate(firstTime, FORMAT_ONE).getTime();
  145. long second = stringtoDate(secTime, FORMAT_ONE).getTime();
  146. return (second - first) / 1000;
  147. }
  148.  
  149. /**
  150. * 获得某月的天数
  151. *
  152. * @param year
  153. * int
  154. * @param month
  155. * int
  156. * @return int
  157. */
  158. public static int getDaysOfMonth(String year, String month) {
  159. int days = 0;
  160. if (month.equals("1") || month.equals("3") || month.equals("5")
  161. || month.equals("7") || month.equals("8") || month.equals("10")
  162. || month.equals("12")) {
  163. days = 31;
  164. } else if (month.equals("4") || month.equals("6") || month.equals("9")
  165. || month.equals("11")) {
  166. days = 30;
  167. } else {
  168. if ((Integer.parseInt(year) % 4 == 0 && Integer.parseInt(year) % 100 != 0)
  169. || Integer.parseInt(year) % 400 == 0) {
  170. days = 29;
  171. } else {
  172. days = 28;
  173. }
  174. }
  175.  
  176. return days;
  177. }
  178.  
  179. /**
  180. * 获取某年某月的天数
  181. *
  182. * @param year
  183. * int
  184. * @param month
  185. * int 月份[1-12]
  186. * @return int
  187. */
  188. public static int getDaysOfMonth(int year, int month) {
  189. Calendar calendar = Calendar.getInstance();
  190. calendar.set(year, month - 1, 1);
  191. return calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
  192. }
  193.  
  194. /**
  195. * 获得当前日期
  196. *
  197. * @return int
  198. */
  199. public static int getToday() {
  200. Calendar calendar = Calendar.getInstance();
  201. return calendar.get(Calendar.DATE);
  202. }
  203.  
  204. /**
  205. * 获得当前月份
  206. *
  207. * @return int
  208. */
  209. public static int getToMonth() {
  210. Calendar calendar = Calendar.getInstance();
  211. return calendar.get(Calendar.MONTH) + 1;
  212. }
  213.  
  214. /**
  215. * 获得当前年份
  216. *
  217. * @return int
  218. */
  219. public static int getToYear() {
  220. Calendar calendar = Calendar.getInstance();
  221. return calendar.get(Calendar.YEAR);
  222. }
  223.  
  224. /**
  225. * 返回日期的天
  226. *
  227. * @param date
  228. * Date
  229. * @return int
  230. */
  231. public static int getDay(Date date) {
  232. Calendar calendar = Calendar.getInstance();
  233. calendar.setTime(date);
  234. return calendar.get(Calendar.DATE);
  235. }
  236.  
  237. /**
  238. * 返回日期的年
  239. *
  240. * @param date
  241. * Date
  242. * @return int
  243. */
  244. public static int getYear(Date date) {
  245. Calendar calendar = Calendar.getInstance();
  246. calendar.setTime(date);
  247. return calendar.get(Calendar.YEAR);
  248. }
  249.  
  250. /**
  251. * 返回日期的月份,1-12
  252. *
  253. * @param date
  254. * Date
  255. * @return int
  256. */
  257. public static int getMonth(Date date) {
  258. Calendar calendar = Calendar.getInstance();
  259. calendar.setTime(date);
  260. return calendar.get(Calendar.MONTH) + 1;
  261. }
  262.  
  263. /**
  264. * 计算两个日期相差的天数,如果date2 > date1 返回正数,否则返回负数
  265. *
  266. * @param date1
  267. * Date
  268. * @param date2
  269. * Date
  270. * @return long
  271. */
  272. public static long dayDiff(Date date1, Date date2) {
  273. return (date2.getTime() - date1.getTime()) / 86400000;
  274. }
  275.  
  276. /**
  277. * 比较两个日期的年差
  278. *
  279. * @param befor
  280. * @param after
  281. * @return
  282. */
  283. public static int yearDiff(String before, String after) {
  284. Date beforeDay = stringtoDate(before, LONG_DATE_FORMAT);
  285. Date afterDay = stringtoDate(after, LONG_DATE_FORMAT);
  286. return getYear(afterDay) - getYear(beforeDay);
  287. }
  288.  
  289. /**
  290. * 比较指定日期与当前日期的差
  291. *
  292. * @param befor
  293. * @param after
  294. * @return
  295. */
  296. public static int yearDiffCurr(String after) {
  297. Date beforeDay = new Date();
  298. Date afterDay = stringtoDate(after, LONG_DATE_FORMAT);
  299. return getYear(beforeDay) - getYear(afterDay);
  300. }
  301.  
  302. /**
  303. * 比较指定日期与当前日期的差
  304. * @param before
  305. * @return
  306. */
  307. public static long dayDiffCurr(String before) {
  308. Date currDate = DateUtils.stringtoDate(currDay(), LONG_DATE_FORMAT);
  309. Date beforeDate = stringtoDate(before, LONG_DATE_FORMAT);
  310. return (currDate.getTime() - beforeDate.getTime()) / 86400000;
  311.  
  312. }
  313.  
  314. /**
  315. * 获取每月的第一周
  316. * @param year
  317. * @param month
  318. * @return
  319. */
  320. public static int getFirstWeekdayOfMonth(int year, int month) {
  321. Calendar c = Calendar.getInstance();
  322. c.setFirstDayOfWeek(Calendar.SATURDAY); // 星期天为第一天
  323. c.set(year, month - 1, 1);
  324. return c.get(Calendar.DAY_OF_WEEK);
  325. }
  326.  
  327. /**
  328. * 获取每月的最后一周
  329. * @param year
  330. * @param month
  331. * @return
  332. */
  333. public static int getLastWeekdayOfMonth(int year, int month) {
  334. Calendar c = Calendar.getInstance();
  335. c.setFirstDayOfWeek(Calendar.SATURDAY); // 星期天为第一天
  336. c.set(year, month - 1, getDaysOfMonth(year, month));
  337. return c.get(Calendar.DAY_OF_WEEK);
  338. }
  339.  
  340. /**
  341. * 获得当前日期字符串,格式"yyyy-MM-dd HH:mm:ss"
  342. *
  343. * @return
  344. */
  345. public static String getNow() {
  346. Calendar today = Calendar.getInstance();
  347. return dateToString(today.getTime(), FORMAT_ONE);
  348. }
  349.  
  350. /**
  351. * 根据生日获取星座
  352. *
  353. * @param birth
  354. * YYYY-mm-dd
  355. * @return
  356. */
  357. public static String getAstro(String birth) {
  358. if (!isDate(birth)) {
  359. birth = "2000" + birth;
  360. }
  361. if (!isDate(birth)) {
  362. return "";
  363. }
  364. int month = Integer.parseInt(birth.substring(birth.indexOf("-") + 1,
  365. birth.lastIndexOf("-")));
  366. int day = Integer.parseInt(birth.substring(birth.lastIndexOf("-") + 1));
  367. String s = "魔羯水瓶双鱼牡羊金牛双子巨蟹狮子处女天秤天蝎射手魔羯";
  368. int[] arr = { 20, 19, 21, 21, 21, 22, 23, 23, 23, 23, 22, 22 };
  369. int start = month * 2 - (day < arr[month - 1] ? 2 : 0);
  370. return s.substring(start, start + 2) + "座";
  371. }
  372.  
  373. /**
  374. * 判断日期是否有效,包括闰年的情况
  375. *
  376. * @param date
  377. * YYYY-mm-dd
  378. * @return
  379. */
  380. public static boolean isDate(String date) {
  381. StringBuffer reg = new StringBuffer("^((\\d{2}(([02468][048])|([13579][26]))-?((((0?");
  382. reg.append("[13578])|(1[02]))-?((0?[1-9])|([1-2][0-9])|(3[01])))");
  383. reg.append("|(((0?[469])|(11))-?((0?[1-9])|([1-2][0-9])|(30)))|");
  384. reg.append("(0?2-?((0?[1-9])|([1-2][0-9])))))|(\\d{2}(([02468][12");
  385. reg.append("35679])|([13579][01345789]))-?((((0?[13578])|(1[02]))");
  386. reg.append("-?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))");
  387. reg.append("-?((0?[1-9])|([1-2][0-9])|(30)))|(0?2-?((0?[");
  388. reg.append("1-9])|(1[0-9])|(2[0-8]))))))");
  389. Pattern p = Pattern.compile(reg.toString());
  390. return p.matcher(date).matches();
  391. }
  392.  
  393. /**
  394. * 取得指定日期过 months 月后的日期 (当 months 为负数表示指定月之前);
  395. *
  396. * @param date
  397. * 日期 为null时表示当天
  398. * @param month
  399. * 相加(相减)的月数
  400. */
  401. public static Date nextMonth(Date date, int months) {
  402. Calendar cal = Calendar.getInstance();
  403. if (date != null) {
  404. cal.setTime(date);
  405. }
  406. cal.add(Calendar.MONTH, months);
  407. return cal.getTime();
  408. }
  409.  
  410. /**
  411. * 取得指定日期过 day 天后的日期 (当 day 为负数表示指日期之前);
  412. *
  413. * @param date
  414. * 日期 为null时表示当天
  415. * @param month
  416. * 相加(相减)的月数
  417. */
  418. public static Date nextDay(Date date, int day) {
  419. Calendar cal = Calendar.getInstance();
  420. if (date != null) {
  421. cal.setTime(date);
  422. }
  423. cal.add(Calendar.DAY_OF_YEAR, day);
  424. return cal.getTime();
  425. }
  426.  
  427. /**
  428. * 取得距离今天 day 日的日期
  429. * @param day
  430. * @param format
  431. * @return
  432. * @author chenyz
  433. */
  434. public static String nextDay(int day, String format) {
  435. Calendar cal = Calendar.getInstance();
  436. cal.setTime(new Date());
  437. cal.add(Calendar.DAY_OF_YEAR, day);
  438. return dateToString(cal.getTime(), format);
  439. }
  440.  
  441. /**
  442. * 取得指定日期过 day 周后的日期 (当 day 为负数表示指定月之前)
  443. *
  444. * @param date
  445. * 日期 为null时表示当天
  446. */
  447. public static Date nextWeek(Date date, int week) {
  448. Calendar cal = Calendar.getInstance();
  449. if (date != null) {
  450. cal.setTime(date);
  451. }
  452. cal.add(Calendar.WEEK_OF_MONTH, week);
  453. return cal.getTime();
  454. }
  455.  
  456. /**
  457. * 获取当前的日期(yyyy-MM-dd)
  458. */
  459. public static String currDay() {
  460. return DateUtils.dateToString(new Date(), DateUtils.LONG_DATE_FORMAT);
  461. }
  462.  
  463. /**
  464. * 获取昨天的日期
  465. *
  466. * @return
  467. */
  468. public static String befoDay() {
  469. return befoDay(DateUtils.LONG_DATE_FORMAT);
  470. }
  471.  
  472. /**
  473. * 根据时间类型获取昨天的日期
  474. * @param format
  475. * @return
  476. * @author chenyz
  477. */
  478. public static String befoDay(String format) {
  479. return DateUtils.dateToString(DateUtils.nextDay(new Date(), -1), format);
  480. }
  481.  
  482. /**
  483. * 获取明天的日期
  484. */
  485. public static String afterDay() {
  486. return DateUtils.dateToString(DateUtils.nextDay(new Date(), 1),
  487. DateUtils.LONG_DATE_FORMAT);
  488. }
  489.  
  490. /**
  491. * 取得当前时间距离1900/1/1的天数
  492. *
  493. * @return
  494. */
  495. public static int getDayNum() {
  496. int daynum = 0;
  497. GregorianCalendar gd = new GregorianCalendar();
  498. Date dt = gd.getTime();
  499. GregorianCalendar gd1 = new GregorianCalendar(1900, 1, 1);
  500. Date dt1 = gd1.getTime();
  501. daynum = (int) ((dt.getTime() - dt1.getTime()) / (24 * 60 * 60 * 1000));
  502. return daynum;
  503. }
  504.  
  505. /**
  506. * getDayNum的逆方法(用于处理Excel取出的日期格式数据等)
  507. *
  508. * @param day
  509. * @return
  510. */
  511. public static Date getDateByNum(int day) {
  512. GregorianCalendar gd = new GregorianCalendar(1900, 1, 1);
  513. Date date = gd.getTime();
  514. date = nextDay(date, day);
  515. return date;
  516. }
  517.  
  518. /** 针对yyyy-MM-dd HH:mm:ss格式,显示yyyymmdd */
  519. public static String getYmdDateCN(String datestr) {
  520. if (datestr == null)
  521. return "";
  522. if (datestr.length() < 10)
  523. return "";
  524. StringBuffer buf = new StringBuffer();
  525. buf.append(datestr.substring(0, 4)).append(datestr.substring(5, 7))
  526. .append(datestr.substring(8, 10));
  527. return buf.toString();
  528. }
  529.  
  530. /**
  531. * 获取本月第一天
  532. *
  533. * @param format
  534. * @return
  535. */
  536. public static String getFirstDayOfMonth(String format) {
  537. Calendar cal = Calendar.getInstance();
  538. cal.set(Calendar.DATE, 1);
  539. return dateToString(cal.getTime(), format);
  540. }
  541.  
  542. /**
  543. * 获取本月最后一天
  544. *
  545. * @param format
  546. * @return
  547. */
  548. public static String getLastDayOfMonth(String format) {
  549. Calendar cal = Calendar.getInstance();
  550. cal.set(Calendar.DATE, 1);
  551. cal.add(Calendar.MONTH, 1);
  552. cal.add(Calendar.DATE, -1);
  553. return dateToString(cal.getTime(), format);
  554. }
  555.  
  556. /**
  557. * @desc: 获取系统 Timestamp,如(2014-12-18 17:35:46.651)
  558. * @return Timestamp
  559. */
  560. public static Timestamp getCurrentSysTimestamp(){
  561. Timestamp d = new Timestamp(System.currentTimeMillis());
  562. return d;
  563. }
  564.  
  565. //----------------------------------------以下是(Long和Date)(Long和yyyy-MM-dd)转换---------------------------------------------------
  566.  
  567. /**
  568. * 获取当前时间的秒数 1970/01/01至今的秒数,,等于new Date().getTime()/1000
  569. * @param date
  570. * @return
  571. * @throws Exception
  572. */
  573. public static long getNowTimeStamp()
  574. {
  575. long stamp = 0L;
  576. Date date1 = new Date();
  577. Date date2 = null;
  578. try {
  579. date2 = (new SimpleDateFormat("yyyy/MM/dd HH:mm:ss")).parse("1970/01/01 08:00:00");
  580. } catch (Exception e) {
  581. e.printStackTrace();
  582. }
  583. stamp = (date1.getTime() - date2.getTime()) / 1000L;
  584. return stamp;
  585. }
  586.  
  587. /**
  588. * 获取当前时间的毫秒数 1970/01/01至今的毫秒数,等于new Date().getTime()
  589. * @param date
  590. * @return
  591. * @throws Exception
  592. */
  593. public static long getNowTimeStampMs(){
  594. long stamp = 0L;
  595. Date date1 = new Date();
  596. Date date2 = null;
  597. try {
  598. date2 = (new SimpleDateFormat("yyyy/MM/dd HH:mm:ss")).parse("1970/01/01 08:00:00");
  599. } catch (Exception e) {
  600. e.printStackTrace();
  601. }
  602. stamp = (date1.getTime() - date2.getTime());
  603. return stamp;
  604. }
  605.  
  606. /**
  607. * 时间转换成秒 1970/01/01至今的秒数(Date转long),等于new Date().getTime()/1000
  608. * @param date
  609. * @return
  610. * @throws Exception
  611. */
  612. public static long getTimeStampByDate(Date date)
  613. {
  614. long stamp = 0L;
  615. Date date1 = date;
  616. Date date2 = null;
  617. try {
  618. date2 = (new SimpleDateFormat("yyyy/MM/dd HH:mm:ss")).parse("1970/01/01 08:00:00");
  619. stamp = (date1.getTime() - date2.getTime()) / 1000L;
  620. } catch (Exception e) {
  621. stamp = 0L;
  622. }
  623.  
  624. return stamp;
  625. }
  626.  
  627. /**
  628. * 时间转换成秒 1970/01/01至今的豪秒数(Date转long)
  629. * @param date
  630. * @return
  631. * @throws Exception
  632. */
  633. public static long getTimeStampMsByDate(Date date)
  634. {
  635. long stamp = 0L;
  636. Date date1 = date;
  637. Date date2 = null;
  638. try {
  639. date2 = (new SimpleDateFormat("yyyy/MM/dd HH:mm:ss")).parse("1970/01/01 08:00:00");
  640. stamp = (date1.getTime() - date2.getTime());
  641. } catch (Exception e) {
  642. stamp = 0L;
  643. }
  644.  
  645. return stamp;
  646. }
  647.  
  648. /**
  649. * 将时间由秒转换成指定格式,如(long转:yyyy-MM-dd HH:mm:ss)
  650. * @param second
  651. * @param format
  652. * @return
  653. * @throws Exception
  654. */
  655. public static String getYYYYByTimeStamp(Long second, String format)
  656. {
  657. if(second==null||second==0){
  658. return "";
  659. }
  660. Date da = null;
  661. try {
  662. da = (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).parse("1970-01-01 08:00:00");
  663. } catch (Exception e) {
  664. e.printStackTrace();
  665. }
  666. Date date = new Date(da.getTime() + second * 1000L);
  667. return (new SimpleDateFormat(format)).format(date);
  668. }
  669. /**
  670. * 将时间由毫秒转换成指定格式,如(long转:yyyy-MM-dd HH:mm:ss)
  671. * @param second
  672. * @param format
  673. * @return
  674. * @throws Exception
  675. */
  676. public static String getYYYYbyTimeStampMs(Long second, String format)
  677. {
  678. if(second==null||second==0){
  679. return "";
  680. }
  681. Date da = null;
  682. try {
  683. da = (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).parse("1970-01-01 08:00:00");
  684. } catch (Exception e) {
  685. e.printStackTrace();
  686. }
  687. Date date = new Date(da.getTime() + second );
  688. return (new SimpleDateFormat(format)).format(date);
  689. }
  690.  
  691. /**
  692. * 1970/01/01至今的秒数转换成Date
  693. * @param TimeStamp
  694. * @return
  695. */
  696. public static Date getDateByTimeStamp(Long TimeStamp){
  697. return new Date(TimeStamp*1000);
  698. }
  699.  
  700. /**
  701. * 1970/01/01至今的豪秒数转换成Date
  702. * @param TimeStampMs
  703. * @return
  704. */
  705. public static Date getDateByTimeStampMs(Long TimeStampMs){
  706. return new Date(TimeStampMs);
  707. }
  708.  
  709. }

java日期工具类(Long型,Date型,yyyyMMdd型)等的更多相关文章

  1. Java日期工具类,Java时间工具类,Java时间格式化

    Java日期工具类,Java时间工具类,Java时间格式化 >>>>>>>>>>>>>>>>>&g ...

  2. java日期工具类DateUtil-续一

    上篇文章中,我为大家分享了下DateUtil第一版源码,但就如同文章中所说,我发现了还存在不完善的地方,所以我又做了优化和扩展. 更新日志: 1.修正当字符串日期风格为MM-dd或yyyy-MM时,若 ...

  3. java日期工具类DateUtil-续二

    该版本是一次较大的升级,农历相比公历复杂太多(真佩服古人的智慧),虽然有规律,但涉及到的取舍.近似的感念太多,况且本身的概念就已经很多了,我在网上也是查阅了很多的资料,虽然找到一些计算的方法,但都有些 ...

  4. java日期工具类DateUtil

    一名优秀的程序员,不仅需要有着丰富解决问题的方案,还需要的便是代码的沉淀,这不仅有助于自己快速的开发程序,也有利于保证程序的健壮.那如何才能沉淀自己的”代码“呢?从自己编写util开始其实就是一个不错 ...

  5. java 日期工具类DateUtils

      日期工具类DateUtils CreateTime--2017年5月27日08:48:00Author:Marydon DateUtils.java-对日期类的进一步封装 import java. ...

  6. JAVA 日期工具类的总结

    一般,在项目中,我们会会经常使用到日期的各种方式的处理,在各个业务逻辑操作中,都需要相关的日期操作,因此,实现项目中的日期工具类的提出,还是十分重要的,下面,就项目中常用到的日期的相关操作方式,做了一 ...

  7. Java 日期工具类(日期,月份加减等)--转

    package util; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.C ...

  8. Java 日期格式化,Java 日期工具类,Java Date工具类

    ================================ ©Copyright 蕃薯耀 2020-01-19 https://www.cnblogs.com/fanshuyao/ import ...

  9. java 日期工具类

    import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; imp ...

随机推荐

  1. JavaWeb总结(一)—Servlet

    一.Servlet生命周期 1.Servlet生命周期 Serlet加载---->实例化---->服务---->销毁 2.init() Servlet容器启动时:读取web.xml配 ...

  2. PHP对象相关知识点的总结

    对象传递:一种说法是"PHP对象是通过引用传递的",更准确的说法是别名(标识符)传递,即它们都保存着同一个标识符(ID)的拷贝,这个标识符指向同一个对象的真正内容. <?ph ...

  3. Liferay中利用URL传参数

    业务场景:现在有一个新闻系统,有两个页面,A是新闻列表页面/web/guest/home,B是新闻的详情页面/web/guest/newsview. 业务逻辑为:在A页面中,点击新闻的标题进入B页面, ...

  4. ASP.NET Core 网站在Docker中运行

    Docker作为新一代的虚拟化方式,未来肯定会得到广泛的应用,传统虚拟机的部署方式要保证开发环境.测试环境.UAT环境.生产环境的依赖一致性,需要大量的运维人力,使用Docker我们可以实现一次部署, ...

  5. Twitter数据抓取的方法(二)

    Scraping Tweets Directly from Twitters Search Page – Part 2 Published January 11, 2015 In the previo ...

  6. 利刃 MVVMLight 5:绑定在表单验证上的应用

    表单验证是MVVM体系中的重要一块.而绑定除了推动 Model-View-ViewModel (MVVM) 模式松散耦合 逻辑.数据 和 UI定义 的关系之外,还为业务数据验证方案提供强大而灵活的支持 ...

  7. 程序设计 之 C#实现《拼图游戏》 (下) 原理篇

    前言:在 http://www.cnblogs.com/labixiaohei/p/6698887.html 程序设计 之 C#实现<拼图游戏>(上),上传了各模块代码,而在本文中将详细剖 ...

  8. CF #284 div1 D. Traffic Jams in the Land 线段树

    大意是有n段路,每一段路有个值a,通过每一端路需要1s,如果通过这一段路时刻t为a的倍数,则需要等待1s再走,也就是需要2s通过. 比较头疼的就是相邻两个数之间会因为数字不同制约,一开始想a的范围是2 ...

  9. MAC Mysql 重置密码

    使用mac电脑,当mysql登录密码忘记时,需要重置密码.步骤如下: 1. 关闭当前正在运行的mysql进程. A.进入"偏好设置",选择mysql, 再选"stop m ...

  10. OpenGL 的空间变换(下):空间变换

    通过本文的上篇 OpenGL 的空间变换(上):矩阵在空间几何中的应用 ,我们了解到矩阵的基础概念.并且掌握了矩阵在空间几何中的应用.接下来,我们将结合矩阵来了解 OpenGL 的空间变换. 在使用 ...