List of usage examples for java.util Calendar setTimeInMillis
public void setTimeInMillis(long millis)
From source file:com.rsltc.profiledata.main.MainActivity.java
private static void processDistanceSummary(DataSet dataSet, InfoType type, DistanceSummary summary) { Calendar calendar = Calendar.getInstance(); for (DataPoint dp : dataSet.getDataPoints()) { Float distance = null;/* w w w .ja v a 2 s. co m*/ Log.i(TAG, "Data point:"); Log.i(TAG, "\tType: " + dp.getDataType().getName()); Long startTime = dp.getStartTime(TimeUnit.MILLISECONDS); calendar.setTimeInMillis(startTime); Log.i(TAG, "\tStart: " + calendar.getTime()); Long stopTime = dp.getEndTime(TimeUnit.MILLISECONDS); calendar.setTimeInMillis(stopTime); Log.i(TAG, "\tStop: " + calendar.getTime()); Long duration = stopTime - startTime; Log.i(TAG, "Timezone: " + calendar.getTimeZone().getDisplayName()); for (Field field : dp.getDataType().getFields()) { Log.i(TAG, "\tField: " + field.getName() + " Value: " + dp.getValue(field)); if (field.equals(Field.FIELD_DISTANCE)) { distance = dp.getValue(field).asFloat(); } else { Log.e(TAG, "Unsupported field found"); } } boolean valid = false; if (distance != null) { valid = HealthStatValidityChecker.checkIfNormalDistance(distance, type); } if (valid) { summary.setMaxDistanceIfGreater(distance); summary.setMinDistanceIfSmaller(distance); summary.setMaxDurationIfLonger(duration); summary.setMinDurationIfShorter(duration); double count = summary.getCount(); summary.setAvgDistance((summary.getAvgDistance() * count + distance) / (count + 1)); summary.setAvgDuration((float) ((summary.getAvgDuration() * count + duration) / (count + 1))); summary.increaseCount(); } } }
From source file:com.projity.server.data.mspdi.TimephasedGetter.java
public void execute(Object arg0) { if (!consumer.acceptValue(functor.getValue())) return; //hack LC TimephasedDataType timephasedDataType; //try {/*from w w w .j a v a 2s . c o m*/ timephasedDataType = factory.createTimephasedDataType(); // } catch (JAXBException e) { // e.printStackTrace(); // return; // } timephasedDataType.setType(this.type); timephasedDataType.setUID(this.id); // System.out.println("Id is " + id); timephasedDataType.setUnit(BigInteger.valueOf(3L)); HasStartAndEnd interval = (HasStartAndEnd) arg0; Calendar startCal = DateTime.calendarInstance(); startCal.setTimeInMillis(DateTime.fromGmt(interval.getStart())); // for 2007, convert from gmt Calendar endCal = DateTime.calendarInstance(); endCal.setTimeInMillis(DateTime.fromGmt(interval.getEnd())); // for 2007, convert from gmt timephasedDataType.setStart(startCal); timephasedDataType.setFinish(endCal); double v = functor.getValue() / WorkCalendar.MILLIS_IN_HOUR; net.sf.mpxj.Duration d = net.sf.mpxj.Duration.getInstance(v, TimeUnit.HOURS); XsdDuration xsdDuration = new XsdDuration(d); timephasedDataType.setValue(xsdDuration.toString()); consumer.consumeTimephased(timephasedDataType); }
From source file:LogEntry.java
public LogEntry(long myId, String myHostname, long myTimestamp, String myMessage, int myFacility, int myPriority) { id = myId;/* w ww.j a va2s .c o m*/ host = myHostname; timestamp = myTimestamp; Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(timestamp); DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss.SSS"); timestampString = formatter.format(calendar.getTime()); facility = myFacility; if (facility >= 0 && facility < facilityStrings.length) { facilityString = facilityStrings[facility]; } else { facilityString = "unknown"; } priority = myPriority; if (priority >= 0 && priority < priorityStrings.length) { priorityString = priorityStrings[priority]; } else { priorityString = "unknown"; } message = myMessage; }
From source file:com.c123.billbuddy.client.MerchantFeeder.java
/** * Creates SpaceDocument with the terms between Merchant and BillBuddy *//* w ww. j av a2 s . c o m*/ private void createMerchantContract(Integer merchantId) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(System.currentTimeMillis()); DocumentProperties documentProperties = new DocumentProperties(); // 1. Create the properties: documentProperties.setProperty("transactionPrecentFee", Double.valueOf(Math.random() / 10)) .setProperty("contractDate", calendar.getTime()).setProperty("merchantId", merchantId); // 2. Create the document using the type name and properties: SpaceDocument document = new SpaceDocument("ContractDocument", documentProperties); // 3. Write the document to the space: gigaSpace.write(document); log.info(String.format("Added MerchantContract object with id '%s'", document.getProperty("id"))); }
From source file:com.lfv.yada.net.server.ServerLogger.java
public synchronized void resume(int h, int m, int s) { // Create a calendar Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC")); cal.setTimeInMillis(System.currentTimeMillis()); cal.set(Calendar.HOUR_OF_DAY, h); cal.set(Calendar.MINUTE, m);// w ww . j a v a2s . co m cal.set(Calendar.SECOND, s); resumeTime = cal.getTimeInMillis(); startTime = System.currentTimeMillis(); suspendTime = 0; }
From source file:net.sf.l2j.gameserver.instancemanager.clanhallsiege.FortResistSiegeManager.java
private FortResistSiegeManager() { _log.info("Fortress Of Resistence"); long siegeDate = restoreSiegeDate(21); Calendar tmpDate = Calendar.getInstance(); tmpDate.setTimeInMillis(siegeDate); setSiegeDate(tmpDate);/* w ww . java 2 s. c o m*/ setNewSiegeDate(siegeDate, 21, 22); _clansDamageInfo = new HashMap<Integer, DamageInfo>(); // Schedule siege auto start _startSiegeTask.schedule(1000); }
From source file:org.openmeetings.test.calendar.TestAppointmentAddAppointment.java
@Test public void saveAppointment() { log.debug("- 1 MeetingReminderJob.execute"); log.warn("- 2 MeetingReminderJob.execute"); try {/* w ww . java 2 s . com*/ //Simulate webapp path //ScopeApplicationAdapter.webAppPath = "./WebContent"; Calendar start = Calendar.getInstance(); start.setTimeInMillis(start.getTimeInMillis() + 600000); Calendar end = Calendar.getInstance(); end.setTimeInMillis(start.getTimeInMillis() + 600000); String appointmentName = "Test 01"; String appointmentDescription = "Descr"; Long users_id = 1L; String appointmentLocation = "office"; Boolean isMonthly = false; Date appointmentstart = start.getTime(); Date appointmentend = end.getTime(); Boolean isDaily = false; Long categoryId = 1L; Boolean isWeekly = false; Long remind = 3L; Boolean isYearly = false; List<Map<String, String>> mmClient = new LinkedList<Map<String, String>>(); for (int i = 0; i < 1; i++) { mmClient.add(createClientObj("firstname" + i, "lastname" + i, "first" + i + ".last" + i + "@webbase-design.de", "Etc/GMT+1")); } Long language_id = 1L; String baseUrl = "http://localhost:5080/openmeetings/"; Long roomType = 1L; Long id = appointmentLogic.saveAppointment(appointmentName, users_id, appointmentLocation, appointmentDescription, appointmentstart, appointmentend, isDaily, isWeekly, isMonthly, isYearly, categoryId, remind, mmClient, roomType, baseUrl, language_id, false, ""); Thread.sleep(3000); appointmentLogic.doScheduledMeetingReminder(); Thread.sleep(3000); assertTrue("Saved appointment should have valid id: " + id, id != null && id > 0); } catch (Exception err) { log.error("[saveAppointment]", err); } }
From source file:net.sf.l2j.gameserver.instancemanager.clanhallsiege.DevastatedCastleManager.java
private DevastatedCastleManager() { _log.info("Fortress Of Resistence"); long siegeDate = restoreSiegeDate(21); Calendar tmpDate = Calendar.getInstance(); tmpDate.setTimeInMillis(siegeDate); setSiegeDate(tmpDate);// w w w . java2 s . c om setNewSiegeDate(siegeDate, 34, 22); _clansDamageInfo = new HashMap<Integer, DamageInfo>(); // Schedule siege auto start _startSiegeTask.schedule(1000); }
From source file:DateUtil.java
/** * Returns the "timestamp" string representation of the time in milliseconds: * yyyy/mm/dd HH:MM:SS/*www. jav a2 s. co m*/ * * @param millis * The milliseconds since epoch to format. * @return The timestamp string. */ public static String toTimestamp(long millis) { Calendar c = Calendar.getInstance(); c.setTimeInMillis(millis); return DateUtil.toTimestamp(c); }
From source file:DateUtil.java
/** * Returns the "short timestamp" string representation of the time in * milliseconds: HH:MM:SS/*from w ww. ja v a 2 s . c o m*/ * * @param millis * The milliseconds since epoch to format. * @return The short timestamp string. */ public static String toShortTimestamp(long millis) { Calendar c = Calendar.getInstance(); c.setTimeInMillis(millis); return DateUtil.toShortTimestamp(c); }