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
/** * Calculates the number of days between Epoch and the given date. * * @param date the date./* w ww .jav a2 s .c om*/ * @return the number of days between Epoch and the given date. */ public static int daysSince1900(Date date) { final Calendar calendar = Calendar.getInstance(); calendar.clear(); calendar.set(1900, 0, 1); return daysBetween(calendar.getTime(), date); }
From source file:de.tbuchloh.kiskis.persistence.XMLProcessing.java
public static String createShortDate(final Calendar cal) { return DATE_SHORT.format(cal.getTime()); }
From source file:com.holyeye.demo.domain.BaseDateEntity.java
public static String getTime(String format) { Calendar cal = Calendar.getInstance(); SimpleDateFormat sdf = new SimpleDateFormat(format); return sdf.format(cal.getTime()); }
From source file:Main.java
public static String getTodayDate() { TimeZone currZone = TimeZone.getTimeZone("Asia/Singapore"); Calendar myCal = Calendar.getInstance(currZone, new Locale("en")); SimpleDateFormat sdf = new SimpleDateFormat(); sdf.applyPattern("yyyy-MM-dd"); return (sdf.format(myCal.getTime())); }
From source file:Main.java
static Date getExpirationDate(int tokenExpiredDateInMinuite) { final Calendar expiredTime = new GregorianCalendar(); // access token is only valid for a hour expiredTime.add(Calendar.MINUTE, tokenExpiredDateInMinuite); return expiredTime.getTime(); }
From source file:Main.java
public static Date round2Day(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date);//from w w w .j a v a 2 s.co m cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); return cal.getTime(); }
From source file:Main.java
public static String getDayOfWeekString(int day) { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.DAY_OF_WEEK, day); SimpleDateFormat format = new SimpleDateFormat("EEE", Locale.US); return format.format(calendar.getTime()); }
From source file:Main.java
public static String getMonthOfYearString(int month) { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.MONTH, month - 1); SimpleDateFormat format = new SimpleDateFormat("MMM", Locale.US); return format.format(calendar.getTime()); }
From source file:Main.java
public static String getMonthName(int month) { Calendar cal = Calendar.getInstance(); SimpleDateFormat month_date = new SimpleDateFormat("MMM"); cal.set(Calendar.MONTH, month - 1); String month_name = month_date.format(cal.getTime()); return month_name; }
From source file:com.hp.hpl.jena.sparql.util.Utils.java
private static String calcTimezone(Calendar cal) { Date date = cal.getTime(); TimeZone z = cal.getTimeZone(); int tz = z.getRawOffset(); if (z.inDaylightTime(date)) { int tzDst = z.getDSTSavings(); tz = tz + tzDst;/* ww w.j a va 2 s . c o m*/ } String sign = "+"; if (tz < 0) { sign = "-"; tz = -tz; } int tzH = tz / (60 * 60 * 1000); // Integer divide towards zero. int tzM = (tz - tzH * 60 * 60 * 1000) / (60 * 1000); String tzH_str = Integer.toString(tzH); String tzM_str = Integer.toString(tzM); if (tzH < 10) tzH_str = "0" + tzH_str; if (tzM < 10) tzM_str = "0" + tzM_str; return sign + tzH_str + ":" + tzM_str; }