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 Date getDistanceDate(Date date, int day) { Calendar cal = Calendar.getInstance(); cal.setTime(date);// w ww . jav a 2 s . co m cal.add(Calendar.DATE, day); return cal.getTime(); }
From source file:Main.java
public static String currentDate() { Calendar c = Calendar.getInstance(); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); return df.format(c.getTime()); }
From source file:Main.java
public static String getDate(long milliSeconds) { SimpleDateFormat formatter = new SimpleDateFormat("EEEE dd MMMM yyyy", Locale.FRANCE); Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(milliSeconds); return formatter.format(calendar.getTime()); }
From source file:Main.java
public static String getHour(long milliSeconds) { SimpleDateFormat formatter = new SimpleDateFormat("kk:mm", Locale.FRANCE); Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(milliSeconds); return formatter.format(calendar.getTime()); }
From source file:Main.java
public static String format(long timeInMillis) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(timeInMillis); return timeFormat.format(calendar.getTime()); }
From source file:Main.java
public static String calendarToShortDateBr(Calendar data) { SimpleDateFormat sdf = new SimpleDateFormat("MMM/yyyy", Locale.getDefault()); return sdf.format(data.getTime()); }
From source file:Main.java
public static Date getDateObj(int year, int month, int day) { Calendar c = new GregorianCalendar(); c.set(year, month - 1, day);/*from w ww.ja v a2 s. c o m*/ return c.getTime(); }
From source file:Main.java
public static Date offsiteDate(Date date, int calendarField, int offsite) { Calendar cal = Calendar.getInstance(); cal.setTime(date);/*from w w w .ja va 2 s . co m*/ cal.add(calendarField, offsite); return cal.getTime(); }
From source file:Main.java
@SuppressLint("SimpleDateFormat") static String setTime() { // add DateTime to filename Calendar cal = Calendar.getInstance(TimeZone.getDefault()); Date currentLocalTime = cal.getTime(); SimpleDateFormat date = new SimpleDateFormat("HH-mm-ss"); date.setTimeZone(TimeZone.getDefault()); _currentTime = date.format(currentLocalTime); return _currentTime; }
From source file:Main.java
public static String getBeforeTodayWithFormat(int gap, String dateFormat) { Calendar currentCalendar = Calendar.getInstance(); currentCalendar.add(Calendar.DATE, gap); Date date = currentCalendar.getTime(); SimpleDateFormat format = new SimpleDateFormat(dateFormat); return format.format(date); }