List of usage examples for java.util Calendar getTime
public final Date getTime()
Date
object representing this Calendar
's time value (millisecond offset from the Epoch"). From source file:Main.java
public static String nowDate() { Calendar cal = Calendar.getInstance(); SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW); return sdf.format(cal.getTime()); }
From source file:Main.java
/** * Returns yesterday's date formatted according to the HTTP specification * standard date format.//from w w w . ja va 2s .co m * * @return a formatted string. */ public static String getExpiredHttpDateString() { Calendar cal = Calendar.getInstance(); cal.add(Calendar.DAY_OF_YEAR, -1); return getHttpDateString(cal.getTime()); }
From source file:Main.java
public static String getDateFormattedRecent(Date date, int daysAgo) { //display day of the week for activities occurred in the last daysAgo Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DATE, 0 - daysAgo); Date weekAgo = calendar.getTime(); if (date.after(weekAgo)) { return new SimpleDateFormat("EEE").format(date);//EEE, short version of day of the week }/* w ww. j a v a 2s .c o m*/ //otherwise, display the date of the activity else { return new SimpleDateFormat("MM.dd.yy").format(date); } }
From source file:net.sourceforge.fenixedu.util.CalendarUtil.java
public static String date2string(Calendar date) { return DateFormatUtils.format(date.getTime(), "yyyyMMdd"); }
From source file:Main.java
/** * Returns Epoch date, ie. 01/01/1970.// ww w. ja v a 2s . com * * @return Epoch date, ie. 01/01/1970. */ public static Date getEpoch() { final Calendar calendar = Calendar.getInstance(); calendar.clear(); calendar.set(1970, 0, 1); return calendar.getTime(); }
From source file:Main.java
public static String getDateStringByCalendar(Calendar calendar) { final SimpleDateFormat sdf = new SimpleDateFormat(FORMAT_DATE); final String dateString = sdf.format(calendar.getTime()); return dateString; }
From source file:Main.java
public static Date getLastDayOfYear() { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.DATE, calendar.getActualMaximum(Calendar.DATE)); return calendar.getTime(); }
From source file:Main.java
public static String now() { Calendar cal = Calendar.getInstance(); SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW); return sdf.format(cal.getTime()); }
From source file:Main.java
static String getDate() { Calendar calendar = Calendar.getInstance(); SimpleDateFormat df = new SimpleDateFormat("dd MMMM yyyy"); return df.format(calendar.getTime()); }
From source file:org.jfree.chart.demo.YIntervalChartDemo2.java
private static void add(YIntervalSeries yintervalseries, int i, int j, int k, double d, double d1) { Calendar calendar = Calendar.getInstance(); calendar.set(i, j, k);//from ww w .ja v a 2 s. c o m yintervalseries.add(calendar.getTime().getTime(), d, d - d1, d + d1); }