Example usage for java.util Date getMonth

List of usage examples for java.util Date getMonth

Introduction

In this page you can find the example usage for java.util Date getMonth.

Prototype

@Deprecated
public int getMonth() 

Source Link

Document

Returns a number representing the month that contains or begins with the instant in time represented by this Date object.

Usage

From source file:org.openkoala.koala.monitor.common.KoalaDateUtils.java

/**
 * ??<br>//from  www .j  av  a2 s.c om
 * generate by: vakin jiang at 2012-5-21
 * 
 * @param date
 * @return
 */
@SuppressWarnings("deprecation")
public static boolean isLastDayOfMonth(Date date) {
    return DateUtils.addDays(date, 1).getMonth() != date.getMonth();
}

From source file:org.dms.sys.error.AlfrescoRuntimeException.java

/**
 * Generate an error log number - based on MMDDXXXX - where M is month,
 * D is day and X is an atomic integer count.
 * //from  ww  w . j ava 2 s  .  c  o  m
 * @param message       Message to prepend the error log number to 
 * 
 * @return message with error log number prefix
 */
private static String buildErrorLogNumber(String message) {
    // ensure message is not null
    if (message == null) {
        message = "";
    }

    Date today = new Date();
    StringBuilder buf = new StringBuilder(message.length() + 10);
    padInt(buf, today.getMonth(), 2);
    padInt(buf, today.getDate(), 2);
    padInt(buf, errorCounter.getAndIncrement(), 4);
    buf.append(' ');
    buf.append(message);
    return buf.toString();
}

From source file:commonUtils.FunctionUtils.java

public static String DateToDirView() {
    Date inDate = DateTimeUtils.getNow();
    String sYear = ConvertUtils.toString(inDate.getYear() + 1900);
    int iNumber = inDate.getMonth() + 1;
    String sMonth = iNumber >= 10 ? ConvertUtils.toString(iNumber) : "0" + ConvertUtils.toString(iNumber);
    iNumber = inDate.getDate();/*from  ww w  . j  av a 2s  .  c  o  m*/
    String sDay = iNumber >= 10 ? ConvertUtils.toString(iNumber) : "0" + ConvertUtils.toString(iNumber);

    return ConvertUtils.toString(sYear + sMonth + sDay);
}

From source file:org.gaixie.micrite.common.search.SearchFactory.java

/**
 * ?//from  w  w  w  . j  av  a 2 s .  co  m
 * @param searchBean
 * @return 0120??
 */
public static int getSearchMonth(SearchBean[] searchBean) {
    if (searchBean == null || searchBean.length == 0)
        return 0;
    Date date;
    for (int i = 0; i < searchBean.length; i++) {
        date = checkDate(StringUtils.split(searchBean[i].getValue(), ";")[0]);
        if (date == null)
            continue;
        return date.getMonth() + 1;
    }
    return 0;
}

From source file:com.qingzhi.apps.fax.util.UIUtils.java

public static String getDataFormat(String time) {
    String formatTime = "";
    try {/*from w  w  w. j  a va2  s  . com*/
        Date date = new SimpleDateFormat("yyyy-MM-dd kk:mm:ss.SSS").parse(time);
        Date nowDate = new Date();
        if (date.getYear() == nowDate.getYear() && date.getMonth() == nowDate.getMonth()
                && date.getDate() == nowDate.getDate()) {
            formatTime = "" + new SimpleDateFormat("HH:mm:ss").format(date);
        } else if (date.getYear() == nowDate.getYear() && date.getMonth() == nowDate.getMonth()
                && date.getDate() == (nowDate.getDate() - 1)) {
            formatTime = "" + new SimpleDateFormat("HH:mm:ss").format(date);
        } else if (date.getYear() == nowDate.getYear()) {
            formatTime = new SimpleDateFormat("MM-dd HH:mm").format(date);
        } else {
            formatTime = new SimpleDateFormat("yyyy-MM-dd").format(date);
        }
    } catch (Exception e) {
        formatTime = time;
    }
    return formatTime;
}

From source file:controllers.CNBCProxy.java

private static String CalculateDateFormat(long millis) {
    // Set helping arrays
    String[] monthArr = new String[12];
    String[] dayArr = new String[7];

    // Set month names
    monthArr[0] = "January";
    monthArr[1] = "February";
    monthArr[2] = "March";
    monthArr[3] = "April";
    monthArr[4] = "May";
    monthArr[5] = "June";
    monthArr[6] = "July";
    monthArr[7] = "August";
    monthArr[8] = "September";
    monthArr[9] = "October";
    monthArr[10] = "November";
    monthArr[11] = "December";

    // Set day names
    dayArr[0] = "Sunday";
    dayArr[1] = "Monday";
    dayArr[2] = "Tuesday";
    dayArr[3] = "Wednesday";
    dayArr[4] = "Thursday";
    dayArr[5] = "Friday";
    dayArr[6] = "Saturday";

    /** Create Date object with random date, in order to calculate date of article like 
    the "setTime()" function in Javascript (date since January 1, 1970 00:00:00 gmt)
    **///from w  w  w  .  j  av  a 2  s  .c om

    Date dateObj = new Date(92, 1, 10);

    // Add long number to get article's date
    dateObj.setTime(millis);

    StringBuilder date = new StringBuilder();
    date.append(dayArr[dateObj.getDay()]).append(", ").append(Integer.toString(dateObj.getDate())).append(" ")
            .append(monthArr[dateObj.getMonth()]).append(" ").append(Integer.toString(dateObj.getYear() + 1900))
            .append(" "); // 1900 added to year(see getYear() method's documentation)

    String hours;
    String midnight;

    if (dateObj.getHours() > 12) {
        if (dateObj.getHours() - 12 < 10) {
            hours = "0" + Integer.toString(dateObj.getHours() - 12);
        } else {
            hours = Integer.toString(dateObj.getHours() - 12);
        }
        midnight = "PM";
    } else {
        if (dateObj.getHours() < 10) {
            hours = "0" + Integer.toString(dateObj.getHours());
        } else {
            hours = Integer.toString(dateObj.getHours());
        }
        midnight = "AM";
    }

    date.append(hours).append(":").append(Integer.toString(dateObj.getMinutes()))
            .append(" " + midnight + " ET");

    return date.toString();
}

From source file:DateUtil.java

/**
 * Checks the day, month and year are equal.
 *//* ww  w. j  av a2s . c o m*/
public static boolean dateEquals(java.util.Date d1, java.util.Date d2) {
    if (d1 == null || d2 == null)
        return false;

    return d1.getDate() == d2.getDate() && d1.getMonth() == d2.getMonth() && d1.getYear() == d2.getYear();
}

From source file:DateUtil.java

/**
  * Checks the second, hour, month, day, month and year are equal.
  *//*from   w  w  w. ja  v a  2 s  . c  o  m*/
public static boolean dateTimeEquals(java.util.Date d1, java.util.Date d2) {
    if (d1 == null || d2 == null)
        return false;

    return d1.getDate() == d2.getDate() && d1.getMonth() == d2.getMonth() && d1.getYear() == d2.getYear()
            && d1.getHours() == d2.getHours() && d1.getMinutes() == d2.getMinutes()
            && d1.getSeconds() == d2.getSeconds();
}

From source file:com.sccl.attech.common.utils.DateUtils.java

/**
 * ?/*from   w ww  .j a va  2 s. co  m*/
 * @param date
 * @return 
 */
public static int getLastTimeNum(Date date) {
    Calendar cal = Calendar.getInstance();
    int year = date.getYear() + 1900;
    int month = date.getMonth() + 1;
    cal.set(Calendar.YEAR, year);
    cal.set(Calendar.MONTH, month);
    cal.set(Calendar.DAY_OF_MONTH, 1);
    cal.add(Calendar.DAY_OF_MONTH, -1);
    Date lastDate = cal.getTime();
    int sum = lastDate.getDate();
    return sum;
}

From source file:com.sccl.attech.common.utils.DateUtils.java

/**
 * ??/*from  ww w. j  a  v  a  2s . c om*/
 * @param date
 * @return 
 */
public static Date getLastTimeDate(Date date) {
    Calendar cal = Calendar.getInstance();
    int year = date.getYear() + 1900;
    int month = date.getMonth() + 1;
    cal.set(Calendar.YEAR, year);
    cal.set(Calendar.MONTH, month);
    cal.set(Calendar.DAY_OF_MONTH, 1);
    cal.add(Calendar.DAY_OF_MONTH, -1);
    Date lastDate = cal.getTime();
    lastDate.setHours(23);
    lastDate.setMinutes(59);
    lastDate.setSeconds(59);
    return lastDate;
}