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
static Calendar toNearestWholeHour(Calendar d) { Calendar c = new GregorianCalendar(); c.setTime(d.getTime()); if (c.get(Calendar.MINUTE) >= 30) c.add(Calendar.HOUR, 1);// ww w. j a va 2 s . com c.set(Calendar.MINUTE, 0); c.set(Calendar.SECOND, 0); return c; }
From source file:Main.java
public static Date getNextDate(int days) { Calendar c = Calendar.getInstance(); c.add(Calendar.DAY_OF_WEEK, days); return c.getTime(); }
From source file:Main.java
@SuppressLint("SimpleDateFormat") public static String getCTime(String pattern) { SimpleDateFormat simpleDate = new SimpleDateFormat(pattern); Calendar calendar = Calendar.getInstance(); String currentTime = simpleDate.format(calendar.getTime()); return currentTime; }
From source file:Main.java
public static String getCurTimeStr() { Calendar cal = Calendar.getInstance(); String curDate = dateFormater.get().format(cal.getTime()); return curDate; }
From source file:Main.java
public static String getEndTime() { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date dateNow = new Date(); Calendar cl = Calendar.getInstance(); cl.setTime(dateNow);// ww w .ja v a2 s .c o m Date dateFrom = cl.getTime(); return sdf.format(dateFrom); }
From source file:Main.java
public static Date milisToDate(long miliseconds) { Calendar c = Calendar.getInstance(); c.setTimeInMillis(miliseconds * 1000); return c.getTime(); }
From source file:Main.java
public static String getCurrentDateTimeForFile() { DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd-HHmmss"); Calendar cal = Calendar.getInstance(); String currentDateTimeForFile = dateFormat.format(cal.getTime()); return currentDateTimeForFile; }
From source file:Main.java
public static long getToday() { Calendar cal = Calendar.getInstance(); String curDate = dateFormater2.get().format(cal.getTime()); curDate = curDate.replace("-", ""); return Long.parseLong(curDate); }
From source file:Main.java
private static Date weekDay(int week) { Calendar cal = calendar(); cal.set(Calendar.DAY_OF_WEEK, week); return cal.getTime(); }
From source file:Main.java
public static Date dateWithYear(int year, int month, int day, int h, int m, int s) { Calendar cal = Calendar.getInstance(); cal.set(year, month, day, h, m, s);//w w w. java 2s.co m return cal.getTime(); }