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 getTomorrow(Date from) {
    Calendar c = buildFromDate(from);
    c.add(Calendar.DATE, 1); // number of days to add
    return c.getTime();
}

From source file:Main.java

/**
 * Get the date/*from   w  w  w .  jav a  2s .  c o m*/
 * 
 * @return {@link String}
 */
public static String GetDate() {
    SimpleDateFormat formatter = new SimpleDateFormat("dd-MMM-yyyy");
    Calendar calendar = Calendar.getInstance();
    return formatter.format(calendar.getTime());

}

From source file:Main.java

public static Date getYesterday(Date from) {
    Calendar c = buildFromDate(from);
    c.add(Calendar.DATE, -1); // number of days to add
    return c.getTime();
}

From source file:Main.java

/**
 * Get the data from milliseconds/* www. j a va 2 s. c om*/
 * 
 * @return {@link String}
 */
public static String GetDateFromMilliseconds() {
    DateFormat formatter = new SimpleDateFormat("dd MMM yyyy");
    Calendar calendar = Calendar.getInstance();
    return formatter.format(calendar.getTime());

}

From source file:Main.java

public static Date formatEndDateForObject(String string) {
    Calendar calendar = Calendar.getInstance();
    calendar.setTimeInMillis(Long.valueOf(string));
    return calendar.getTime();
}

From source file:Main.java

public static Date addTimeInterval(Date origin, int value, int unit) {
    Calendar cal = Calendar.getInstance();
    cal.setTime(origin);/*from w  w w .ja v a  2s.c o  m*/
    cal.add(unit, value);
    return cal.getTime();
}

From source file:Main.java

/**
 * Get the time from milliseconds/*from w w w. j a  v a  2s  .  c  o m*/
 * 
 * @return {@link String}
 */
public static String GetTimeFromMilliseconds() {
    DateFormat formatter = new SimpleDateFormat("HH:mm ss SSS");
    Calendar calendar = Calendar.getInstance();
    return formatter.format(calendar.getTime());

}

From source file:Main.java

public static Date formatStartDateForObject(String string) {
    Calendar calendar = Calendar.getInstance();
    calendar.setTimeInMillis(Long.valueOf(string));
    return calendar.getTime();
}

From source file:Main.java

public static String getDateFromCal(String pattern, Calendar cal) {
    DateFormat df = new SimpleDateFormat(pattern, Locale.getDefault());
    return df.format(cal.getTime());
}

From source file:Main.java

public static final String getStandardDate(int day, int month, int year) {
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd", Locale.CHINA);
    Calendar calendar = Calendar.getInstance();
    calendar.set(year, month, day);//from   ww w. j  av  a  2  s.  c  o  m
    return format.format(calendar.getTime());
}