Example usage for java.util Calendar getTime

List of usage examples for java.util Calendar getTime

Introduction

In this page you can find the example usage for java.util Calendar getTime.

Prototype

public final Date getTime() 

Source Link

Document

Returns a Date object representing this Calendar's time value (millisecond offset from the Epoch").

Usage

From source file:Main.java

public static Date getEndFinanacialDate(Date taxdate) {

    Calendar calendar = Calendar.getInstance();
    calendar.setTime(taxdate);//from w  w w . ja v a2s.  c o  m
    int yr = calendar.get(Calendar.YEAR);
    calendar.set(yr, 11, 31);
    taxdate = calendar.getTime();

    return taxdate;
}

From source file:Main.java

public static Date getFinanacialDate(Date taxdate) {

    Calendar calendar = Calendar.getInstance();
    calendar.setTime(taxdate);/* ww  w . j a v a  2  s  . co  m*/
    int yr = calendar.get(Calendar.YEAR);
    calendar.set(yr, 00, 01);
    taxdate = calendar.getTime();

    return taxdate;
}

From source file:Main.java

public static Date getDifferenceDaysDate(long times, int diffDay) {
    Calendar now = Calendar.getInstance();
    Date d = new Date();
    d.setTime(times);/*from   w w  w  . j a v a  2s .  c o m*/
    now.setTime(d);
    now.set(Calendar.DATE, now.get(Calendar.DATE) + diffDay);
    return now.getTime();
}

From source file:ezbake.services.provenance.graph.Utils.java

public static Date getCurrentDate() {
    // zero out millisecond
    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.MILLISECOND, 0);
    return cal.getTime();
}

From source file:Main.java

public static Date nextDay(Date date) {
    Calendar calendar = new GregorianCalendar();
    calendar.setTime(date);//ww w  . j a va2  s  . c om
    calendar.add(calendar.DATE, 1);
    date = calendar.getTime();
    return date;
}

From source file:Main.java

public static Date beginOfTheDay(@NonNull Date date) {
    Calendar inputDate = Calendar.getInstance();
    inputDate.setTime(date);//from  w  w  w .  j a va2  s  .c  o  m

    Calendar resultDate = Calendar.getInstance();
    resultDate.set(inputDate.get(Calendar.YEAR), inputDate.get(Calendar.MONTH),
            inputDate.get(Calendar.DAY_OF_YEAR));
    return resultDate.getTime();
}

From source file:com.edduarte.protbox.core.Constants.java

/**
 * Get the current date and time/*w ww  . j  a  v  a2 s  .com*/
 *
 * @return the current date and time
 */
public static Date getToday() {
    Calendar c = new GregorianCalendar();
    return c.getTime();
}

From source file:net.sourceforge.fenixedu.util.CalendarUtil.java

public static boolean intersectTimes(Calendar startTime1, Calendar endTime1, Calendar startTime2,
        Calendar endTime2) {//from w ww .j a  va 2 s . c o  m
    return intersectTimes(startTime1.getTime(), endTime1.getTime(), startTime2.getTime(), endTime2.getTime());
}

From source file:Main.java

public static String getDateStr(int index) {
    SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd");

    java.util.Calendar calendar = new java.util.GregorianCalendar();

    calendar.add(Calendar.DATE, index);

    String retDate = "";
    try {/*from   www . j  a v a 2 s.c o m*/
        retDate = df.format(calendar.getTime());
    } catch (Exception ex) {
        ex.printStackTrace();
    }

    return retDate;

}

From source file:Main.java

public static String getLastDayOfThisMonth() {
    String str = "";
    Calendar lastDate = Calendar.getInstance();
    lastDate.set(Calendar.DATE, 1);//
    lastDate.add(Calendar.MONTH, 1);//
    lastDate.add(Calendar.DATE, -1);//

    str = sdf.format(lastDate.getTime());
    return str;/*from   w  ww. j a v a 2  s  .c  o m*/
}