Package com.uphea.util

Source Code of com.uphea.util.DateUtil

package com.uphea.util;

import jodd.datetime.JDateTime;

/**
* Time utilities for dates in int-format.
* Int format is: YYYYMMDD.
*/
public class DateUtil {

  /**
   * Converts date to int date format.
   */
  public static int toIntDate(JDateTime jd) {
    return jd.getYear() * 10000 + jd.getMonth() * 100 + jd.getDay();
  }

  /**
   * Converts date to JDateTime.
   */
  public static JDateTime toJDateTime(int date) {
    int year = date / 10000;
    date -= year * 10000;
    int month = date / 100;
    date -= month * 100;
    return new JDateTime(year, month, date);
  }

  /**
   * Returns current date in int format.
   * @see #toIntDate(jodd.datetime.JDateTime)
   */
  public static int currentIntDate() {
    return toIntDate(new JDateTime());
  }

}
TOP

Related Classes of com.uphea.util.DateUtil

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.