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
private static long currentTime() { Calendar time = Calendar.getInstance(); time.add(Calendar.MILLISECOND, -time.getTimeZone().getOffset(time.getTimeInMillis())); return time.getTime().getTime(); }
From source file:Main.java
private static Date get8Hours10MinsAgo() { Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.HOUR, -8); calendar.add(Calendar.MINUTE, -10); return calendar.getTime(); }
From source file:Main.java
public static String toStringReadableTime(Calendar calendar, Context context) { if (DateFormat.is24HourFormat(context)) { return READABLE_TIME_24_FORMAT.format(calendar.getTime()); } else {//from w w w . j a v a 2 s . c o m return READABLE_TIME_FORMAT.format(calendar.getTime()); } }
From source file:Main.java
public static String generateUniqueID() { Calendar cal = Calendar.getInstance(); SimpleDateFormat sdf = new SimpleDateFormat("ddMMyyyyHHmmss", Locale.US); return sdf.format(cal.getTime()); }
From source file:Main.java
public static Date getFirstDayOfMonth(Date dateTime) { if (dateTime == null) return dateTime; Calendar calendar = Calendar.getInstance(); calendar.setTime(dateTime);/*from w w w . j a v a2 s .co m*/ calendar.set(Calendar.DAY_OF_MONTH, 1); return calendar.getTime(); }
From source file:Main.java
public static String getDateTimeString(Calendar cal) { SimpleDateFormat df = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss"); df.setLenient(false);/*from w ww . j av a 2 s . c o m*/ String s = df.format(cal.getTime()); return s; }
From source file:Main.java
public static String getLastFridayofMonth(int offset) { final String DATE_FORMAT_NOW = "dd-MMM-yyyy"; Calendar cal = Calendar.getInstance(); SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW); cal = getLastFriday(cal, offset);//w ww .ja v a 2s. c o m return sdf.format(cal.getTime()); }
From source file:Main.java
public static String getNowTime() { Calendar nowTime = Calendar.getInstance(); nowTime.add(Calendar.HOUR_OF_DAY, 8); return new SimpleDateFormat("yyyyMMddHHmmssSSS").format(nowTime.getTime()); }
From source file:Main.java
public static Date getNextdayDate(Date date) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date);/* w ww.ja v a 2s. c o m*/ calendar.add(Calendar.DATE, 1); return calendar.getTime(); }
From source file:Main.java
public static String getTimeNow() { Calendar cal = Calendar.getInstance(); SimpleDateFormat format = new SimpleDateFormat("HH:ss"); return format.format(cal.getTime()); }