Example usage for java.util Date getDate

List of usage examples for java.util Date getDate

Introduction

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

Prototype

@Deprecated
public int getDate() 

Source Link

Document

Returns the day of the month represented by this Date object.

Usage

From source file:GenerateWorkItems.java

/**
 * @param args// w w  w  .  j  a va2s . 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 date2calendarStr(Date date) {
    return date2calendarStr(date.getYear() + 1900, date.getMonth() + 1, date.getDate());
}

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/* w  w w.j a  v  a 2  s .  c o m*/
        return FMT_DATE2.format(d);
}

From source file:Main.java

@SuppressWarnings("deprecation")
public static String dateFormat(long stamp) {
    Date date = new Date(stamp * 1000);
    Date today = new Date();

    SimpleDateFormat format;/*from   w ww  .j  a  v a  2 s  . c  o m*/
    if (date.getDate() == today.getDate()) {
        format = new SimpleDateFormat("HH:mm");
    } else if (date.getYear() == today.getYear()) {
        format = new SimpleDateFormat("MM-dd HH:mm");
    } else {
        format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
    }

    return format.format(date);
}

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());/*from w w  w  .  java  2s.com*/
}

From source file:Main.java

/**
 * Convert a Date object in a string representing the date at readable style.
 *///from ww w  . ja v a2  s  .  co  m
public static String dateToReadableString(Date date) {
    if (date == null)
        return "";
    else
        return ("" + (date.getYear() + 1900) + "/" + (date.getMonth() + 1) + "/" + date.getDate());
}

From source file:Main.java

public static int milli2int(long milli) {
    Date date = new Date(milli);
    int total = 0;
    int year = date.getYear() - 112;
    int month = date.getMonth() + 1;
    int day = date.getDate();
    int hour = date.getHours();
    int minute = date.getMinutes();
    int sec = date.getSeconds();
    total = year << 26;//from w  w  w  . j  ava 2s .c o  m
    total |= month << 22;
    total |= day << 17;
    total |= hour << 12;
    total |= minute << 6;
    total |= sec;
    return total;
}

From source file:Main.java

public static String formatDate(Date d) {
    // TODO let user pick date format preferences ( - or - consult system settings? )
    String s = (1900 + d.getYear()) + "/" + (d.getMonth() + 1) + "/" + (d.getDate());
    return s;/*from  www  .  j av  a 2s .  c om*/
}

From source file:Main.java

/**
 * Get the long representation of the beginning of the current date
 * @return current date in system time/*  w  w w. j a  v  a2s  .c om*/
 */
public static long getCurrentDateStartLong() {
    final Date currentDate = new Date(System.currentTimeMillis());
    final Date currentDateBeginning = new Date(currentDate.getYear(), currentDate.getMonth(),
            currentDate.getDate());

    return currentDateBeginning.getTime();
}

From source file:irille.pub.svr.DateUtils.java

public static Date getMonthBefore(Date date) {
    return new Date(date.getYear(), date.getMonth() - 1, date.getDate());
}