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:GenerateWorkItems.java

/**
 * @param args/*www .  j av a  2  s  . c o  m*/
 */
public static void main(String[] args) {
    initTorque();
    List issueTypes = issueTypeDAO.loadAll();
    List states = stateDAO.loadAll();
    List persons = PersonBL.loadPersons();
    List priorities = priorityDAO.loadAll();
    List severities = severityDAO.loadAll();
    Integer lastWorkItemID = null;
    for (int i = 0; i < numberOfItems; i++) {
        TWorkItemBean workItemBean = new TWorkItemBean();
        Integer randomProject = new Integer(1);// getRandomObjectIdFromList(projects);
        workItemBean.setListTypeID(getRandomObjectIdFromList(issueTypes));
        /*workItemBean.setProjectCategoryID(
              getRandomObjectIdFromList(subprojectDAO.loadByProject1(randomProject)));*/
        workItemBean.setStateID(getRandomObjectIdFromList(states));
        workItemBean.setOwnerID(getRandomObjectIdFromList(persons));
        workItemBean.setResponsibleID(getRandomObjectIdFromList(persons));
        /*workItemBean.setClassID(
              getRandomObjectIdFromList(classDAO.loadByProject1(randomProject)));*/
        /*workItemBean.setReleaseNoticedID(
              getRandomObjectIdFromList(ReleaseBL.loadNotClosedByProject(randomProject)));
        workItemBean.setReleaseScheduledID(
              getRandomObjectIdFromList(releaseDAO.loadNotClosedByProject(randomProject)));*/
        workItemBean.setPriorityID(getRandomObjectIdFromList(priorities));
        workItemBean.setSeverityID(getRandomObjectIdFromList(severities));
        workItemBean.setOriginatorID(getRandomObjectIdFromList(persons));
        workItemBean.setCreated(new Date());
        workItemBean.setLastEdit(new Date());
        workItemBean.setChangedByID(getRandomObjectIdFromList(persons));
        workItemBean.setSynopsis("Title" + i);
        workItemBean.setBuild("Build" + i);
        if (i % 2 == 1) {
            workItemBean.setSuperiorworkitem(lastWorkItemID);
        }
        Date date = new Date();
        workItemBean.setStartDate(new Date(date.getYear(), date.getMonth(), date.getDate()));
        workItemBean.setEndDate(new Date(date.getYear(), date.getMonth(), date.getDate() + 20));
        workItemBean.setDescription("Some descriptuion for item " + i);
        try {
            lastWorkItemID = workItemDAO.save(workItemBean);
        } catch (ItemPersisterException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        TStateChangeBean stateChangeBean = new TStateChangeBean();
        stateChangeBean.setWorkItemID(workItemBean.getObjectID());
        stateChangeBean.setChangedToID(workItemBean.getStateID());
        stateChangeBean.setChangedByID(workItemBean.getChangedByID());
        stateChangeBean.setLastEdit(workItemBean.getLastEdit());
        stateChangeBean.setChangeDescription("Generated status change text for " + workItemBean.getObjectID());
        stateChangeDAO.save(stateChangeBean);
        System.out.println("Issue number " + workItemBean.getObjectID() + " created.");
    }

}

From source file:Main.java

public static String getSeason(Date date) {
    return seasons[date.getMonth()];
}

From source file:Main.java

public static String getShortMonth(Date date) {
    return shortMonth[date.getMonth()];
}

From source file:Main.java

/**
 * @param date// ww w .  j  a va2 s. c  om
 *
 * @return
 */
public static String getFormatedDate(Date date) {
    return date.getYear() + "-" + date.getMonth() + "-" + date.getDay() + " - At " + date.getHours() + ":"
            + date.getMinutes();
}

From source file:Main.java

public static String date2calendarStr(Date date) {
    return date2calendarStr(date.getYear() + 1900, date.getMonth() + 1, date.getDate());
}

From source file:Main.java

public static int getMonthsDifference(Date date1, Date date2) {
    int m1 = date1.getYear() * 12 + date1.getMonth();
    int m2 = date2.getYear() * 12 + date2.getMonth();
    return m2 - m1 + 1;
}

From source file:Main.java

public static boolean isSameDay(Date date1, Date date2) {
    return date1.getDay() == date2.getDay() && date1.getMonth() == date2.getMonth()
            && date1.getYear() == date2.getYear();
}

From source file:Main.java

public static boolean isSameDay(Date d1, Date d2) {
    return d1.getDay() == d2.getDay() && d1.getMonth() == d2.getMonth() && d1.getYear() == d2.getYear();
}

From source file:Main.java

public static String format(Date d) {
    if (d == null || d.getTime() < ZERO_TIMESTAMP)
        return "";
    Date now = new Date();
    if (now.getYear() == d.getYear() && now.getMonth() == d.getMonth() && now.getDate() == d.getDate())
        return FMT_TIME.format(d);
    else if (now.getYear() == d.getYear())
        return FMT_DATE.format(d);
    else//from w ww .j a  v  a  2 s  . c  om
        return FMT_DATE2.format(d);
}

From source file:Main.java

public static String date2str(Date date) {
    if (date == null)
        return null;

    return date2str(date.getYear() + 1900, date.getMonth() + 1, date.getDate(), date.getHours(),
            date.getMinutes());//  w  ww.  j  av a 2  s  .  com
}