List of usage examples for java.util Calendar getTimeInMillis
public long getTimeInMillis()
From source file:com.clustercontrol.util.HinemosTime.java
/** * Hinemos?????Calendar??<br>/*from w w w . ja v a2s .com*/ * @param timezone * @return */ public static Calendar getCalendarInstance(TimeZone timezone) { Calendar calendar = Calendar.getInstance(timezone); calendar.setTimeInMillis(calendar.getTimeInMillis() + timeOffsetMillis); return calendar; }
From source file:Main.java
/** * Returns a string formatted time//from w w w . j a v a 2 s .co m * * @return String of formatted time. */ static public String getTimeAsString(Calendar c, String format) { if (format.isEmpty()) { format = "hh:mm Hours"; } SimpleDateFormat sdf = new SimpleDateFormat(format); return sdf.format(c.getTimeInMillis()); }
From source file:io.wcm.wcm.commons.caching.ModificationDateTest.java
static void applyLastModified(Resource resource, Calendar value) { ResourceMetadata metadata = new ResourceMetadata(); metadata.setModificationTime(value.getTimeInMillis()); when(resource.getResourceMetadata()).thenReturn(metadata); }
From source file:model.manager.FileManager.java
public static boolean saveTemplate(ReportObject obj) { Date now = new Date(); Calendar C = Calendar.getInstance(); C.setTime(now);/*w ww . jav a 2 s . c o m*/ String fileName = C.getTimeInMillis() + ".xml"; return saveTemplate(obj, fileName); }
From source file:Main.java
public static long getTomorrowZeroTimeInMillis() { Calendar calendar = getZeroSecondCalendar(); calendar.add(Calendar.DAY_OF_YEAR, 1); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); return calendar.getTimeInMillis(); }
From source file:gr.seab.r2rml.beans.MainParser.java
public static void runParcer(String[] args) { Calendar c0 = Calendar.getInstance(); long t0 = c0.getTimeInMillis(); CommandLineParser cmdParser = new PosixParser(); Options cmdOptions = new Options(); cmdOptions.addOption("p", "properties", true, "define the properties file. Example: r2rml-parser -p r2rml.properties"); cmdOptions.addOption("h", "print help", false, "help"); String propertiesFile = "r2rml.properties"; try {//from w ww. j a va 2s . c om if (StringUtils.isNotEmpty(propertiesFile)) { properties.load(new FileInputStream(propertiesFile)); log.info("Loaded properties from " + propertiesFile); if (args != null && args.length > 0 && args[0].equals("fixProperty")) { properties = fixProperty(properties); } } } catch (FileNotFoundException e) { //e.printStackTrace(); String err = "Properties file not found (" + propertiesFile + ")."; log.error(err); throw new RuntimeException(err); //System.exit(0); } catch (IOException e) { //e.printStackTrace(); String err = "Error reading properties file (" + propertiesFile + ")."; log.error(err); throw new RuntimeException(err); //System.exit(0); } ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("app-context.xml"); Database db = (Database) context.getBean("db"); db.setProperties(properties); Parser parser = (Parser) context.getBean("parser"); parser.setProperties(properties); MappingDocument mappingDocument = parser.parse(); mappingDocument.getTimestamps().add(t0); //0 Started mappingDocument.getTimestamps().add(Calendar.getInstance().getTimeInMillis()); //1 Finished parsing. Starting generating result model. Generator generator = (Generator) context.getBean("generator"); generator.setProperties(properties); generator.setResultModel(parser.getResultModel()); //Actually do the output generator.createTriples(mappingDocument); context.close(); Calendar c1 = Calendar.getInstance(); long t1 = c1.getTimeInMillis(); log.info("Finished in " + (t1 - t0) + " milliseconds. Done."); mappingDocument.getTimestamps().add(Calendar.getInstance().getTimeInMillis()); //5 Finished. //log.info("5 Finished."); //output the result for (int i = 0; i < mappingDocument.getTimestamps().size(); i++) { if (i > 0) { long l = (mappingDocument.getTimestamps().get(i).longValue() - mappingDocument.getTimestamps().get(i - 1).longValue()); //System.out.println(l); log.info(String.valueOf(l)); } } log.info("Parse. Generate in memory. Dump to disk/database. Log. - Alltogether in " + String.valueOf(mappingDocument.getTimestamps().get(5).longValue() - mappingDocument.getTimestamps().get(0).longValue()) + " msec."); log.info("Done."); System.out.println("Done."); }
From source file:com.clustercontrol.util.HinemosTime.java
/** * Hinemos?????Calendar??<br>/*from w w w . ja v a 2 s.c o m*/ * @param timezone * @param locale * @return */ public static Calendar getCalendarInstance(TimeZone timezone, Locale locale) { Calendar calendar = Calendar.getInstance(timezone, locale); calendar.setTimeInMillis(calendar.getTimeInMillis() + timeOffsetMillis); return calendar; }
From source file:Main.java
/** * Get relativy days base on today, will return negative and positive * values./* w w w . j a v a2s. c om*/ * * @param d * @return */ public static long getRelativeDays(Date d) { Calendar c = Calendar.getInstance(); c.set(Calendar.HOUR_OF_DAY, 0); c.set(Calendar.MINUTE, 0); c.set(Calendar.SECOND, 0); c.set(Calendar.MILLISECOND, 0); long curMilli = c.getTimeInMillis(); c.setTimeInMillis(d.getTime()); c.set(Calendar.HOUR_OF_DAY, 0); c.set(Calendar.MINUTE, 0); c.set(Calendar.SECOND, 0); c.set(Calendar.MILLISECOND, 0); long dMilli = c.getTimeInMillis(); return (dMilli - curMilli) / (1 * 24 * 3600 * 1000); }
From source file:Main.java
public static long convertTime(long timestamp, String fromTimeZone, String toTimeZone) { Calendar fromCal = new GregorianCalendar(TimeZone.getTimeZone(fromTimeZone)); fromCal.setTimeInMillis(timestamp);/*from w w w . ja va 2 s .c o m*/ Calendar toCal = new GregorianCalendar(TimeZone.getTimeZone(toTimeZone)); toCal.setTimeInMillis(fromCal.getTimeInMillis()); return toCal.getTimeInMillis(); }
From source file:Main.java
public static long convertTZ(long timestamp, String fromTimeZone, String toTimeZone) { Calendar fromCal = new GregorianCalendar(TimeZone.getTimeZone(fromTimeZone)); fromCal.setTimeInMillis(timestamp);//from ww w . j a v a2 s . com Calendar toCal = new GregorianCalendar(TimeZone.getTimeZone(toTimeZone)); toCal.setTimeInMillis(fromCal.getTimeInMillis()); return toCal.getTimeInMillis(); }