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 boolean areEqualMonth(Calendar c1, Calendar c2) { SimpleDateFormat sdf = new SimpleDateFormat("MM-yyyy"); return (sdf.format(c1.getTime()).equals(sdf.format(c2.getTime()))); }
From source file:Main.java
public static String parseDateToString(long lastModify) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(lastModify); Date date = calendar.getTime(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss", Locale.CHINA); String time = sdf.format(date); return time;/*from ww w.ja va 2 s . c om*/ }
From source file:Main.java
/** * Get time and date//from www. j a va 2s . com * * @return {@link String} */ public static String GetTimeandDate() { DateFormat formatter = new SimpleDateFormat("[dd-MMM-yyyy|HH:mm:ss]"); Calendar calendar = Calendar.getInstance(); return formatter.format(calendar.getTime()); }
From source file:Main.java
/** * My son's birthday! This serves no purpose OTHER than a shoutout to him, love ya kid. * @return Date object/*from w w w . ja v a 2 s. c om*/ */ public static Date getLiamsBirthday() { Calendar calendar = Calendar.getInstance(); calendar.set(2016, 7, 4, 12, 29, 30); Date date = calendar.getTime(); return date; }
From source file:Main.java
public static String addDay(int day) { DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd", Locale.getDefault()); Calendar cal = Calendar.getInstance(); cal.add(Calendar.DATE, day);/* w w w . j ava2 s . c om*/ return dateFormat.format(cal.getTime()); }
From source file:Main.java
/** * Get time and date without datalogger format * //from www . ja va 2 s . c o m * @return {@link String} */ public static String GetTimeandDateUpdate() { DateFormat formatter = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss"); Calendar calendar = Calendar.getInstance(); return formatter.format(calendar.getTime()); }
From source file:Main.java
public static String ToString(Calendar date) { SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy", Locale.US); return sdf.format(date.getTime()); }
From source file:Main.java
public static String calendar2TimeString(Calendar calendar) { SimpleDateFormat format = new SimpleDateFormat("MM-dd HH:mm"); return format.format(calendar.getTime()); }
From source file:Main.java
public static String GetFormatDateStrByMillseconds(long milliseconds) { Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(milliseconds);/*from w ww . ja v a2 s.co m*/ return GetFormatedDate(cal.getTime()); }
From source file:Main.java
/** * For when I need a quick date in the year 1985. Don't judge me, I get lazy and don't * want to type my birthday multiple times. * @return Date object//from ww w. j ava2 s . c om */ public static Date get1985() { Calendar calendar = Calendar.getInstance(); calendar.set(1985, 10, 8, 11, 11, 11); Date date = calendar.getTime(); return date; }