List of usage examples for java.util Calendar setTimeInMillis
public void setTimeInMillis(long millis)
From source file:Main.java
public static Date formatStartDateForObject(String string) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(Long.valueOf(string)); return calendar.getTime(); }
From source file:Main.java
public static String GetFormatedDateForQuotedPrice(long milliseconds) { Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(milliseconds); return GetFormatedDateForQuotedPrice(cal.getTime()); }
From source file:Main.java
public static String GetFormatDateStrByMillseconds(long milliseconds) { Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(milliseconds); return GetFormatedDate(cal.getTime()); }
From source file:Main.java
public static String getDateFromMillies(long milliSeconds, String dateFormat) { SimpleDateFormat formatter = new SimpleDateFormat(dateFormat); Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(milliSeconds); return formatter.format(calendar.getTime()); }
From source file:Main.java
public static String getMsgTime(long msg_time) { Calendar cl = Calendar.getInstance(); cl.setTimeInMillis(msg_time); //here your time in miliseconds String hour = String.format("%02d", cl.get(Calendar.HOUR_OF_DAY)); String min = String.format("%02d", cl.get(Calendar.MINUTE)); String sec = String.format("%02d", cl.get(Calendar.SECOND)); String time = hour + ":" + min; return time;/* w w w .jav a 2s. c o m*/ }
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
private static Calendar add(long time, int val, int field) { Calendar c = Calendar.getInstance(); c.setTimeInMillis(time); if (field == 666) { c.add(Calendar.MONTH, val * 3); } else {//w w w.ja va 2 s.c o m c.add(field, val); } return c; }
From source file:Main.java
public static Calendar getEndOfDate(long time) { Calendar ret = Calendar.getInstance(); ret.setTimeInMillis(time); ret.set(Calendar.HOUR_OF_DAY, 23); ret.set(Calendar.MINUTE, 59); ret.set(Calendar.SECOND, 59); ret.set(Calendar.MILLISECOND, 999); return ret;/*from w ww .j av a 2s .com*/ }
From source file:Main.java
/** * transform a Time object into an equivalent Calendar (used in display events) * @param time/* ww w . j a v a 2 s. c o m*/ * @return */ public static Calendar timeToCalendar(Time time) { long millis = time.toMillis(false); Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(millis); return cal; }
From source file:Main.java
public static String format(long timeInMillis) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(timeInMillis); return timeFormat.format(calendar.getTime()); }