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 parseDateTime(long timeInMillis) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(timeInMillis); Date date = calendar.getTime(); return formatDateTime(date); }
From source file:Main.java
public static String previousDateString(String dateString) throws ParseException { DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd"); Date myDate = dateFormat.parse(dateString); Calendar calendar = Calendar.getInstance(); calendar.setTime(myDate);// ww w .j ava 2s .c o m calendar.add(Calendar.DAY_OF_YEAR, -1); Date previousDate = calendar.getTime(); String result = dateFormat.format(previousDate); return result; }
From source file:Main.java
public static String getDateString(Calendar date) { SimpleDateFormat format = new SimpleDateFormat("d MMMM yyyy", Locale.getDefault()); return format.format(date.getTime()); }
From source file:com.nabla.wapp.server.general.Util.java
public static java.sql.Date calendarToSqlDate(final Calendar dt) { return new java.sql.Date(dt.getTime().getTime()); }
From source file:Main.java
public static Date addMouth(Date date, int step) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date);/*from www . j a va 2 s .co m*/ calendar.add(Calendar.MONTH, step); return calendar.getTime(); }
From source file:Main.java
public static Date getDate(int hour, int time, int year, int month, int day) { final Calendar calendar = Calendar.getInstance(); calendar.set(year, month, day, hour, time); Date date = calendar.getTime(); return date;//from ww w. ja va 2 s . c o m }
From source file:Main.java
public static Date getDate(int year, int month, int day, int hour, int min, int sec) { Calendar calendar = Calendar.getInstance(); calendar.set(year, (month - 1), day, hour, min, sec); return calendar.getTime(); }
From source file:Main.java
public static String nowTime() { Calendar cal = Calendar.getInstance(); SimpleDateFormat sdf = new SimpleDateFormat(TIME_FORMAT_NOW); return sdf.format(cal.getTime()); }
From source file:Main.java
public static String getDateFromTimeStamp(long timestamp) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("d MMM"); Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(timestamp * 1000); return simpleDateFormat.format(calendar.getTime()); }
From source file:Main.java
public static String date2Str(Calendar c, String format) { if (c == null) { return null; }//from ww w . j a va2 s. co m return date2Str(c.getTime(), format); }