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:common.util.DateUtil.java

public static String getWeekShortLabel(Date date, String lang) {
    System.out.println("getWeekShortLabel date = " + date);
    return date == null ? "" : getMonthShort(lang)[date.getMonth()] + " " + date.getDate();
}

From source file:Main.java

public static String getDateForHistory(String dateString) {
    String[] shortMonths = new DateFormatSymbols().getShortMonths();

    SimpleDateFormat parserSDF = new SimpleDateFormat("yyyy-MM-dd");
    SimpleDateFormat formater = new SimpleDateFormat("dd");
    String month = "";

    parserSDF.setTimeZone(TimeZone.getTimeZone("UTC"));
    formater.setTimeZone(TimeZone.getTimeZone("UTC"));
    Date date = null;
    try {/* w ww  .  j  a v a 2s  .co  m*/
        parserSDF.setTimeZone(TimeZone.getTimeZone("UTC"));
        date = parserSDF.parse(dateString);
        month = shortMonths[date.getMonth()];
    } catch (ParseException e) {
        Log.d(TAG, e.getMessage());
    }

    return month + " " + formater.format(date);
}

From source file:Main.java

static public void appendDateNode(Document owner, Element appendElement, String name, Date date) {
    Element dateElem = owner.createElement(name);
    appendElement.appendChild(dateElem);
    appendSingleValElement(owner, dateElem, "month", Integer.toString(date.getMonth() + 1));
    appendSingleValElement(owner, dateElem, "day", Integer.toString(date.getDate()));
    appendSingleValElement(owner, dateElem, "year", Integer.toString(date.getYear() + 1900));
    appendSingleValElement(owner, dateElem, "hour", Integer.toString(date.getHours()));
    appendSingleValElement(owner, dateElem, "minute", Integer.toString(date.getMinutes()));
    appendSingleValElement(owner, dateElem, "second", Integer.toString(date.getSeconds()));
}

From source file:Main.java

public static int getMonth(String sDate) {
    DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
    Date d = null;
    try {//w ww.j  a v  a 2 s  .c om
        d = df.parse(sDate);
    } catch (ParseException e) {
        e.printStackTrace();
    }
    if (d == null) {
        return 0;
    }
    return d.getMonth();
}

From source file:Main.java

public static String getXMLDateString() {
    Date date = new Date();
    // YYYY-MM-DDThh:mm:ss

    // Must be a simpler way to do this....
    String xmlDateFormat = "" + (date.getYear() + 1900);
    int month = (date.getMonth() + 1);
    String monthStr = fillZero(month);
    String dateStr = fillZero(date.getDate());
    xmlDateFormat = xmlDateFormat + "-" + monthStr;
    xmlDateFormat = xmlDateFormat + "-" + dateStr;
    xmlDateFormat = xmlDateFormat + "T" + fillZero(date.getHours());
    xmlDateFormat = xmlDateFormat + ":" + fillZero(date.getMinutes());
    xmlDateFormat = xmlDateFormat + ":" + fillZero(date.getSeconds());

    return (xmlDateFormat);
}

From source file:ch.ethz.inf.vs.android.g54.a4.util.SnapshotCache.java

private static String constructFileName(String name) {
    Date d = new Date();
    return String.format("%d-%d-%d_%d-%d-%d_%s.%s", d.getYear() + 1900, d.getMonth(), d.getDay(), d.getHours(),
            d.getMinutes(), d.getSeconds(), name, FILE_EXTENSION);
}

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

public static int subMonth(Date d1, Date d2) {
    int suby = d2.getYear() - d1.getYear();
    int rst = (suby + 1) * 12;
    rst = rst - d1.getMonth();
    rst = rst - (11 - d2.getMonth());/*from w  ww  .  j a va 2  s.com*/
    return rst;
}

From source file:Main.java

public static int compareDates(java.util.Date startDate, java.util.Date endDate) {
    int interval = 0;

    calendarStartDate = Calendar.getInstance();
    calendarStartDate.set(Calendar.YEAR, startDate.getYear());
    calendarStartDate.set(Calendar.MONTH, startDate.getMonth());
    calendarStartDate.set(Calendar.DAY_OF_MONTH, startDate.getDate());

    calendarEndDate.set(Calendar.YEAR, endDate.getYear());
    calendarEndDate.set(Calendar.MONTH, endDate.getMonth());
    calendarEndDate.set(Calendar.DAY_OF_MONTH, endDate.getDate());

    long diff = calendarEndDate.getTimeInMillis() - calendarStartDate.getTimeInMillis();
    interval = (int) (diff / (24 * 60 * 60 * 1000) + 1); // plus one day

    return interval;
}

From source file:org.openmrs.module.vcttrac.web.view.chart.VCTCreateBarChartView.java

/**
 * Auto generated method comment// w w w .  j  av a 2  s .c  o m
 * 
 * @return
 */
private static CategoryDataset createMonthDataset() {

    Date curDate = new Date();

    int numberOfRepetitions = curDate.getMonth() + 1;

    VCTModuleService vms = Context.getService(VCTModuleService.class);

    // create the dataset...
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    int month = 0;

    while (month < numberOfRepetitions) {
        double value = vms.getNumberOfClientByMonthAndYearOfRegistration(month + 1, curDate.getYear() + 1900);
        dataset.addValue(value, "year", VCTTracUtil.getMessage("vcttrac.month." + (month + 1), null));
        month += 1;
    }

    return dataset;

}

From source file:org.alfresco.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  w w  w .  j a v a  2 s.  co 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(MESSAGE_DELIMITER);
    buf.append(message);
    return buf.toString();
}