List of usage examples for java.util Calendar setTimeInMillis
public void setTimeInMillis(long millis)
From source file:com.pureinfo.srm.config.notice.TestTimer.java
public static void main(String[] args) throws ParseException { Calendar start = new GregorianCalendar(); start.setTime(format.parse("18:40")); Calendar cal = new GregorianCalendar(); start.set(Calendar.YEAR, cal.get(Calendar.YEAR)); start.set(Calendar.MONTH, cal.get(Calendar.MONTH)); start.set(Calendar.DAY_OF_MONTH, cal.get(Calendar.DAY_OF_MONTH)); while (start.before(cal)) { start.setTimeInMillis(start.getTimeInMillis() + DateUtils.MILLIS_PER_MINUTE); }/*from w w w .j a v a 2s . c o m*/ new Timer().scheduleAtFixedRate(new test1(), start.getTime(), DateUtils.MILLIS_PER_MINUTE); }
From source file:com.krawler.common.util.StringUtil.java
public static void main(String args[]) { // dump("this is a test"); // dump("this is 'a nother' test"); // dump("this is\\ test"); // dump("first Roland last 'Schemers' full 'Roland Schemers'"); // dump("multi 'Roland\\nSchemers'"); // dump("a"); // dump(""); // dump("\\ \\ "); // dump("backslash \\\\"); // dump("backslash \\f"); // dump("a b"); // TimeZone.setDefault(TimeZone.getTimeZone("GMT")); //// getUserTimeZoneDate("CST"); ///*from w ww .j av a 2s.co m*/ // String olddate = "Tue Sep 29 06:33:19 GMT 2010"; // // System.out.println(issameDatesExTime(new Date(),olddate)); Calendar cal = Calendar.getInstance(); Calendar cal1 = new GregorianCalendar(TimeZone.getTimeZone("GMT" + "+5:30")); try { Date dt = new Date(); cal1.setTimeInMillis(dt.getTime()); cal.set(Calendar.YEAR, cal1.get(Calendar.YEAR)); cal.set(Calendar.MONTH, cal1.get(Calendar.MONTH)); cal.set(Calendar.DAY_OF_MONTH, cal1.get(Calendar.DAY_OF_MONTH)); cal.set(Calendar.HOUR_OF_DAY, cal1.get(Calendar.HOUR_OF_DAY)); cal.set(Calendar.MINUTE, cal1.get(Calendar.MINUTE)); cal.set(Calendar.SECOND, cal1.get(Calendar.SECOND)); cal.set(Calendar.MILLISECOND, cal1.get(Calendar.MILLISECOND)); System.out.println("IST timezone dt: " + cal.getTime() + " Date is: " + dt); } catch (Exception ex) { System.out.println(ex); } finally { //return cal.getTime(); } /*Date date = new Date(); System.out.println(date); SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy"); //SimpleDateFormat sdf = new SimpleDateFormat("MM-dd-yyyy HH:mm:ss"); sdf.setTimeZone(TimeZone.getTimeZone("CST")); // replace timezine with user timezone String datestr = sdf.format(date); System.out.println(datestr); String[] datearr = datestr.split(" "); String newstr = datestr.replace(datearr[4], " "); Date newdate = new Date(newstr); System.out.println(newdate);*/ // datearr[datearr.length-1]="GMT"; // String newstr = ""; // for (int i = 0; i < datearr.length; i++) { // if (i != 4) { // newstr += datearr[i] + " "; // }else{ // newstr += "GMT "; // } // } // newstr = newstr.substring(0, newstr.length() - 1); }
From source file:Main.java
public static String currentTime() { Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(firstCall + (offset * 1000 * 60)); SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss"); offset++;//ww w. ja v a 2 s .c o m return sdf.format(cal.getTime()); }
From source file:Main.java
public static Calendar copyFromNow(Calendar aoCalendar) { aoCalendar.setTimeInMillis(Calendar.getInstance().getTimeInMillis()); return aoCalendar; }
From source file:Main.java
public static Calendar fromMillis(long millis) { Calendar calendar = now(); calendar.setTimeInMillis(millis); return calendar; }
From source file:Main.java
public static String getClockTimeFromSeconds(long secs) { Calendar c = Calendar.getInstance(); c.setTimeInMillis(secs * 1000L); return String.format("%02d:%02d", c.get(Calendar.HOUR_OF_DAY), c.get(Calendar.MINUTE)); }
From source file:Main.java
public static String getDateTimeString(long time) { Calendar c = Calendar.getInstance(); c.setTimeInMillis(time); return c.getTime().toString(); }
From source file:Main.java
private static Calendar add(long time, int val, int field) { Calendar c = Calendar.getInstance(); c.setTimeInMillis(time); c.add(field, val); return c;/*from ww w . ja v a 2 s . c o m*/ }
From source file:Main.java
public static int getYear(long date) { Calendar c = Calendar.getInstance(); c.setTimeInMillis(date); return c.get(Calendar.YEAR); }
From source file:Main.java
public static Date milisToDate(long miliseconds) { Calendar c = Calendar.getInstance(); c.setTimeInMillis(miliseconds * 1000); return c.getTime(); }