List of usage examples for java.util Calendar toString
@Override
public String toString()
From source file:com.yangtsaosoftware.pebblemessenger.services.MessageProcessingService.java
@Override public void onCreate() { super.onCreate(); phone_is_ontalking = false;/*from w ww .j ava 2 s . c o m*/ loadPrefs(); Thread proceedthread = new ProcessThread(); proceedthread.start(); messageHandler = new MessageHandler(Looper.getMainLooper()); mMessenger = new Messenger(messageHandler); MessageProcessingService._context = getApplicationContext(); fdb = new FontDbHandler(_context); fdb.open(); mdb = new MessageDbHandler(_context); mdb.open(); bindService(new Intent(this, PebbleCenter.class), connToPebbleCenter, Context.BIND_AUTO_CREATE); BroadcastReceiver br = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { int command = intent.getIntExtra(Constants.BROADCAST_COMMAND, Constants.BROADCAST_PREFER_CHANGED); switch (command) { case Constants.BROADCAST_PREFER_CHANGED: loadPrefs(); break; case Constants.BROADCAST_CALL_INCOMING: String number = intent.getStringExtra(Constants.BROADCAST_PHONE_NUM); String name = intent.getStringExtra(Constants.BROADCAST_NAME); if (callQuietEnable) { Calendar c = Calendar.getInstance(); Calendar now = new GregorianCalendar(0, 0, 0, c.get(Calendar.HOUR_OF_DAY), c.get(Calendar.MINUTE)); Constants.log(TAG_NAME, "Checking quiet hours. Now: " + now.toString() + " vs " + quiet_hours_before.toString() + " and " + quiet_hours_after.toString()); if (now.before(quiet_hours_before) || now.after(quiet_hours_after)) { Constants.log(TAG_NAME, "Time is before or after the quiet hours time. Returning."); addNewCall(number, name, MessageDbHandler.NEW_ICON); } else { Bundle b = new Bundle(); b.putLong(MessageDbHandler.COL_CALL_ID, addNewCall(number, name, MessageDbHandler.OLD_ICON)); b.putString(MessageDbHandler.COL_CALL_NUMBER, number); b.putString(MessageDbHandler.COL_CALL_NAME, name); Message innerMsg = processHandler.obtainMessage(INNER_CALL_PROCEED); innerMsg.setData(b); processHandler.sendMessage(innerMsg); } } else { Bundle b = new Bundle(); if (phone_is_ontalking) { b.putString(MessageDbHandler.COL_MESSAGE_APP, "Call"); b.putString(MessageDbHandler.COL_MESSAGE_CONTENT, name + "\n" + number); addNewCall(number, name, MessageDbHandler.NEW_ICON); b.putLong(MessageDbHandler.COL_MESSAGE_ID, addNewMessage(b, MessageDbHandler.OLD_ICON)); Message innerMsg = processHandler.obtainMessage(INNER_MESSAGE_PROCEED); innerMsg.setData(b); processHandler.sendMessage(innerMsg); } else { b.putLong(MessageDbHandler.COL_CALL_ID, addNewCall(number, name, MessageDbHandler.OLD_ICON)); b.putString(MessageDbHandler.COL_CALL_NUMBER, number); b.putString(MessageDbHandler.COL_CALL_NAME, name); Message innerMsg = processHandler.obtainMessage(INNER_CALL_PROCEED); innerMsg.setData(b); processHandler.sendMessage(innerMsg); } } break; case Constants.BROADCAST_CALL_HOOK: phone_is_ontalking = true; break; case Constants.BROADCAST_CALL_IDLE: phone_is_ontalking = false; break; case Constants.BROADCAST_SMS_INCOMING: { Message msg = Message.obtain(); msg.what = MSG_NEW_MESSAGE; Bundle b = new Bundle(); b.putString(MessageDbHandler.COL_MESSAGE_APP, "SMS"); b.putString(MessageDbHandler.COL_MESSAGE_CONTENT, intent.getStringExtra(Constants.BROADCAST_SMS_BODY)); msg.setData(b); messageHandler.sendMessage(msg); } } } }; IntentFilter intentFilter = new IntentFilter(MessageProcessingService.class.getName()); LocalBroadcastManager.getInstance(getApplicationContext()).registerReceiver(br, intentFilter); }
From source file:org.wikipedia.nirvana.archive.ArchiveWithHeaders.java
void initLatestItemHeaderHeader(NirvanaWiki wiki, ArchiveSettings aSettings) { latestItemHeaderHeader = null;/*from w w w .j ava 2 s . co m*/ if (!addToTop) { if (this.parts.size() > 0) { Section items = parts.get(0); if (items.getHeaderHeader() == null) { for (int i = items.getSize() - 1; i >= 0; i--) { Calendar c = NewPages.getNewPagesItemDate(wiki, items.getItem(i)); if (c != null) { latestItemHeaderHeader = aSettings.getHeaderHeaderForDate(c); log.debug("latestItemHeaderHeader : " + latestItemHeaderHeader + " for date: " + c.toString()); return; } } } } } }
From source file:com.heliumv.api.production.ProductionApi.java
private boolean updateOpenWorkEntryImpl(OpenWorkUpdateEntry updateEntry) throws NamingException, RemoteException { if (updateEntry.getId() == null) { respondBadRequestValueMissing("updateEntry.id"); return false; }/*from www . j a v a 2 s.c om*/ if (StringHelper.isEmpty(updateEntry.getProductionCnr())) { respondBadRequestValueMissing("updateEntry.lotCnr"); return false; } LosDto losDto = fertigungCall.losFindByCNrMandantCNrOhneExc(updateEntry.getProductionCnr()); if (losDto == null) { respondNotFound("updateEntry.lotCnr", updateEntry.getProductionCnr()); return false; } LossollarbeitsplanDto arbeitsplanDto = fertigungCall .lossollarbeitsplanFindByPrimaryKey(updateEntry.getId()); // Minimale Absicherung gegen Versuche die Id "frei" zu ermitteln if (!arbeitsplanDto.getLosIId().equals(losDto.getIId())) { respondNotFound("updateEntry.id", updateEntry.getId().toString()); return false; } MaschineDto maschineDto = null; if (updateEntry.getMachineId() != null) { maschineDto = zeiterfassungCall.maschineFindByPrimaryKey(updateEntry.getMachineId()); } Calendar beginCal = Calendar.getInstance(); beginCal.setTime(losDto.getTProduktionsbeginn()); Calendar newCal = Calendar.getInstance(); newCal.setTimeInMillis(updateEntry.getWorkItemStartDate()); newCal.set(Calendar.HOUR_OF_DAY, 0); newCal.set(Calendar.MINUTE, 0); newCal.set(Calendar.SECOND, 0); newCal.set(Calendar.MILLISECOND, 0); if (newCal.compareTo(beginCal) < 0) { respondBadRequest("updateEntry.workItemStartDate", newCal.toString() + " < production.startDate"); return false; } int dayDiff = daysBetween(beginCal, newCal); arbeitsplanDto.setIMaschinenversatztage(dayDiff); if (maschineDto != null) { arbeitsplanDto.setMaschineIId(maschineDto.getIId()); } if (updateEntry.getMachineOffsetMs() != null) { arbeitsplanDto.setIMaschinenversatzMs(updateEntry.getMachineOffsetMs()); } else { arbeitsplanDto.setIMaschinenversatzMs(0); } fertigungCall.updateLossollarbeitsplan(arbeitsplanDto); return true; }
From source file:com.thinkbiganalytics.metadata.modeshape.support.JcrPropertyUtil.java
public static void setProperty(Node node, String name, Object value) { try {/*from w w w . j av a2 s . co m*/ //ensure checked out // JcrVersionUtil.ensureCheckoutNode(node); if (node == null) { throw new IllegalArgumentException("Cannot set a property on a null-node!"); } if (name == null) { throw new IllegalArgumentException("Cannot set a property without a provided name"); } if (value == null) { node.setProperty(name, (Value) null); } else if (value instanceof Enum) { node.setProperty(name, ((Enum) value).name()); } else if (value instanceof JcrObject) { node.setProperty(name, ((JcrObject) value).getNode()); } else if (value instanceof Value) { node.setProperty(name, (Value) value); } else if (value instanceof Node) { node.setProperty(name, (Node) value); } else if (value instanceof Binary) { node.setProperty(name, (Binary) value); } else if (value instanceof Calendar) { node.setProperty(name, (Calendar) value); } else if (value instanceof DateTime) { Calendar cal = Calendar.getInstance(); cal.setTime(((DateTime) value).toDate()); node.setProperty(name, cal); } else if (value instanceof Date) { Calendar cal = Calendar.getInstance(); cal.setTime((Date) value); node.setProperty(name, cal); } else if (value instanceof BigDecimal) { node.setProperty(name, (BigDecimal) value); } else if (value instanceof Long) { node.setProperty(name, ((Long) value).longValue()); } else if (value instanceof Double) { node.setProperty(name, (Double) value); } else if (value instanceof Boolean) { node.setProperty(name, (Boolean) value); } else if (value instanceof InputStream) { node.setProperty(name, (InputStream) value); } else if (value instanceof Collection) { String[] list = new String[((Collection<Object>) value).size()]; int pos = 0; for (Object cal : (Collection<Object>) value) { list[pos] = cal.toString(); pos += 1; } node.setProperty(name, list); } else { node.setProperty(name, value.toString()); } } catch (AccessDeniedException e) { log.debug("Access denied", e); throw new AccessControlException(e.getMessage()); } catch (RepositoryException e) { throw new MetadataRepositoryException("Failed to set property value: " + name + "=" + value, e); } }
From source file:org.everit.jira.timetracker.plugin.JiraTimetrackerPluginImpl.java
private List<EntityCondition> createWorklogQueryExprList(final ApplicationUser user, final Calendar startDate, final Calendar endDate) { String userKey = user.getKey(); EntityExpr startExpr = new EntityExpr("startdate", EntityOperator.GREATER_THAN_EQUAL_TO, new Timestamp(startDate.getTimeInMillis())); EntityExpr endExpr = new EntityExpr("startdate", EntityOperator.LESS_THAN, new Timestamp(endDate.getTimeInMillis())); EntityExpr userExpr = new EntityExpr("author", EntityOperator.EQUALS, userKey); LOGGER.info(/*from w ww .ja v a 2 s . com*/ "JTTP LOG: getWorklogs start date: " + startDate.toString() + " end date:" + endDate.toString()); List<EntityCondition> exprList = new ArrayList<EntityCondition>(); exprList.add(userExpr); exprList.add(startExpr); exprList.add(endExpr); return exprList; }
From source file:com.gitstudy.rili.liarbry.CalendarView.java
/** * ?/*from w w w .j a v a2s. com*/ * APItry cache * * @param calendar calendar */ public final void removeSchemeDate(Calendar calendar) { if (calendar == null) { return; } if (mDelegate.mSchemeDatesMap == null || mDelegate.mSchemeDatesMap.size() == 0) { return; } if (mDelegate.mSchemeDatesMap.containsKey(calendar.toString())) { mDelegate.mSchemeDatesMap.remove(calendar.toString()); } if (mDelegate.mSelectedCalendar.equals(calendar)) { mDelegate.clearSelectedScheme(); } mSelectLayout.update(); mMonthPager.updateScheme(); mWeekPager.updateScheme(); }
From source file:org.everit.jira.timetracker.plugin.JiraTimetrackerPluginImpl.java
private List<EntityCondition> createWorklogQueryExprListWithPermissionCheck(final String selectedUser, final ApplicationUser loggedInUser, final Calendar startDate, final Calendar endDate) throws GenericEntityException { String userKey = ((selectedUser == null) || "".equals(selectedUser)) ? loggedInUser.getKey() : selectedUser; List<Long> projects = createProjects(loggedInUser); EntityExpr startExpr = new EntityExpr("startdate", EntityOperator.GREATER_THAN_EQUAL_TO, new Timestamp(startDate.getTimeInMillis())); EntityExpr endExpr = new EntityExpr("startdate", EntityOperator.LESS_THAN, new Timestamp(endDate.getTimeInMillis())); EntityExpr userExpr = new EntityExpr("author", EntityOperator.EQUALS, userKey); EntityExpr projectExpr = new EntityExpr("project", EntityOperator.IN, projects); LOGGER.info(//www . j a v a 2 s .com "JTTP LOG: getWorklogs start date: " + startDate.toString() + " end date:" + endDate.toString()); List<EntityCondition> exprList = new ArrayList<EntityCondition>(); exprList.add(userExpr); exprList.add(startExpr); exprList.add(endExpr); exprList.add(projectExpr); return exprList; }
From source file:org.atricore.idbus.capabilities.sso.main.sp.producers.AssertionConsumerProducer.java
private void validateAssertionConditions(ResponseType response, ConditionsType conditions) throws SSOException, SSOResponseException { if (conditions == null) return;/* w w w .ja v a 2 s . c om*/ long tolerance = ((AbstractSSOMediator) channel.getIdentityMediator()).getTimestampValidationTolerance(); Calendar utcCalendar = Calendar.getInstance(TimeZone.getTimeZone("UTC")); if (conditions.getConditionOrAudienceRestrictionOrOneTimeUse() == null && conditions.getNotBefore() == null && conditions.getNotOnOrAfter() == null) { return; } logger.debug("Current time (UTC): " + utcCalendar.toString()); XMLGregorianCalendar notBeforeUTC = null; XMLGregorianCalendar notOnOrAfterUTC = null; if (conditions.getNotBefore() != null) { //normalize to UTC logger.debug("Conditions.NotBefore: " + conditions.getNotBefore()); notBeforeUTC = conditions.getNotBefore().normalize(); logger.debug("Conditions.NotBefore normalized: " + notBeforeUTC.toString()); if (!notBeforeUTC.isValid()) { throw new SSOResponseException(response, StatusCode.TOP_REQUESTER, StatusCode.INVALID_ATTR_NAME_OR_VALUE, StatusDetails.INVALID_UTC_VALUE, notBeforeUTC.toString()); } else { Calendar notBefore = notBeforeUTC.toGregorianCalendar(); notBefore.add(Calendar.MILLISECOND, (int) tolerance * -1); if (utcCalendar.before(notBefore)) throw new SSOResponseException(response, StatusCode.TOP_REQUESTER, StatusCode.INVALID_ATTR_NAME_OR_VALUE, StatusDetails.NOT_BEFORE_VIOLATED, notBeforeUTC.toString()); } } // Make sure that the NOT ON OR AFTER is not violated, give a five minutes tolerance (should be configurable) if (conditions.getNotOnOrAfter() != null) { //normalize to UTC logger.debug("Conditions.NotOnOrAfter: " + conditions.getNotOnOrAfter().toString()); notOnOrAfterUTC = conditions.getNotOnOrAfter().normalize(); logger.debug("Conditions.NotOnOrAfter normalized: " + notOnOrAfterUTC.toString()); if (!notOnOrAfterUTC.isValid()) { throw new SSOResponseException(response, StatusCode.TOP_REQUESTER, StatusCode.INVALID_ATTR_NAME_OR_VALUE, StatusDetails.INVALID_UTC_VALUE, notOnOrAfterUTC.toString()); } else { // diff in millis Calendar notOnOrAfter = notOnOrAfterUTC.toGregorianCalendar(); notOnOrAfter.add(Calendar.MILLISECOND, (int) tolerance); if (utcCalendar.after(notOnOrAfter)) throw new SSOResponseException(response, StatusCode.TOP_REQUESTER, StatusCode.INVALID_ATTR_NAME_OR_VALUE, StatusDetails.NOT_ONORAFTER_VIOLATED, notOnOrAfterUTC.toString()); } } if (notBeforeUTC != null && notOnOrAfterUTC != null && notOnOrAfterUTC.compare(notBeforeUTC) <= 0) { throw new SSOResponseException(response, StatusCode.TOP_REQUESTER, StatusCode.INVALID_ATTR_NAME_OR_VALUE, StatusDetails.INVALID_CONDITION, "'Not On or After' earlier that 'Not Before'"); } // Our SAMLR2 Enityt ID should be part of the audience CircleOfTrustMemberDescriptor sp = this.getCotMemberDescriptor(); MetadataEntry spMd = sp.getMetadata(); if (spMd == null || spMd.getEntry() == null) throw new SSOException("No metadata descriptor found for SP " + sp); EntityDescriptorType md = null; if (spMd.getEntry() instanceof EntityDescriptorType) { md = (EntityDescriptorType) spMd.getEntry(); } else throw new SSOException("Unsupported Metadata type " + md + ", SAML 2 Metadata expected"); if (conditions.getConditionOrAudienceRestrictionOrOneTimeUse() != null) { boolean audienceRestrictionValid = false; boolean spInAllAudiences = false; boolean initState = true; for (ConditionAbstractType conditionAbs : conditions.getConditionOrAudienceRestrictionOrOneTimeUse()) { if (conditionAbs instanceof AudienceRestrictionType) { AudienceRestrictionType audienceRestriction = (AudienceRestrictionType) conditionAbs; if (audienceRestriction.getAudience() != null) { boolean spInAudience = false; for (String audience : audienceRestriction.getAudience()) { if (audience.equals(md.getEntityID())) { spInAudience = true; break; } } spInAllAudiences = (initState ? spInAudience : spInAllAudiences && spInAudience); initState = false; } } audienceRestrictionValid = audienceRestrictionValid || spInAllAudiences; } if (!audienceRestrictionValid) { logger.error("SP is not in Audience list."); throw new SSOResponseException(response, StatusCode.TOP_REQUESTER, StatusCode.INVALID_ATTR_NAME_OR_VALUE, StatusDetails.NOT_IN_AUDIENCE); } } }
From source file:edu.cmu.mpcs.dashboard.TagViewer.java
private String alarmSetting(String settingString) { if (settingString.contains("set alarm")) { /** Set Alarm **/ String hour = settingString.substring(settingString.indexOf("#") + 1, settingString.indexOf("*")); String minute = settingString.substring(settingString.indexOf("*") + 1, settingString.indexOf("|")); Log.d("timePicker", hour + ":" + minute); int hr = Integer.parseInt(hour); int min = Integer.parseInt(minute); Log.d("Alarm", "hr:" + hr + "min:" + min); Calendar cal = Calendar.getInstance(); // add minutes to the calendar object ////from w w w. j ava2s.co m cal.set(Calendar.HOUR_OF_DAY, hr); cal.set(Calendar.MINUTE, min); cal.set(Calendar.SECOND, 0); // cal.add(Calendar.MINUTE, 1); Intent alarmintent = new Intent(getApplicationContext(), AlarmReceiver.class); alarmintent.putExtra("title", "Alarm for " + hour + ":" + minute); alarmintent.putExtra("note", "Touch to turn off Alarm"); // HELLO_ID is a static variable that must be // initialised at the BEGINNING OF CLASS with 1; PendingIntent sender = PendingIntent.getBroadcast(getApplicationContext(), HELLO_ID, alarmintent, PendingIntent.FLAG_UPDATE_CURRENT | Intent.FILL_IN_DATA); // VERY IMPORTANT TO SET FLAG_UPDATE_CURRENT... // this will send correct extra's informations // to // AlarmReceiver Class // Get the AlarmManager service AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE); am.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), sender); Log.i("Alarm", "AlarmSet" + cal.toString()); // /** Auto-sync **/ // // if (!ContentResolver.getMasterSyncAutomatically()) // ContentResolver.setMasterSyncAutomatically(true); // else { // ContentResolver.setMasterSyncAutomatically(false); // } return ("AlarmSet for : " + hour + ":" + min + "\n"); } return (""); }
From source file:org.jasig.portlet.calendar.adapter.BlackboardVistaICalAdapter.java
/** * Retrieve calendar data from Blackboard and use it to * build an iCal4j Calendar object./*from w ww . ja v a 2s . c om*/ * * @param url URL of the calendar to be retrieved * @param session A valid Blackboard session for the user * @param period period time period to retrieve events for * @return ical4j Calendar object */ protected net.fortuna.ical4j.model.Calendar getCalendar(String soapSvrUrl, SessionVO session, Period period) throws CalendarException { Calendar beginPeriod = Calendar.getInstance(); beginPeriod.setTime(period.getStart()); beginPeriod.set(Calendar.HOUR_OF_DAY, 0); beginPeriod.set(Calendar.MINUTE, 0); beginPeriod.set(Calendar.SECOND, 0); beginPeriod.set(Calendar.MILLISECOND, 0); Calendar endPeriod = Calendar.getInstance(); endPeriod.setTime(period.getEnd()); endPeriod.set(Calendar.HOUR_OF_DAY, 0); endPeriod.set(Calendar.MINUTE, 0); endPeriod.set(Calendar.SECOND, 0); endPeriod.set(Calendar.MILLISECOND, 0); try { net.fortuna.ical4j.model.Calendar iCal4j = new net.fortuna.ical4j.model.Calendar(); iCal4j.getProperties().add(new ProdId("-//Ben Fortuna//iCal4j 1.0//EN")); iCal4j.getProperties().add(Version.VERSION_2_0); iCal4j.getProperties().add(CalScale.GREGORIAN); // Display the PersonId from Context SDK. long personID = session.getSubject().getPersonID(); // Get the Calendar SDK Service based on the passed in URL CalendarSDK calSvc = new CalendarSDK(new URL(soapSvrUrl + "Calendar")); // Get the Calendar entries for the person. log.info("Get Calendar entries for personID = " + personID); CalendarEntryVO[] calEntries = calSvc.getEntriesForUser(session, personID); if (calEntries != null && calEntries.length != 0) { for (int i = 0; i < calEntries.length; i++) { log.debug("id = " + calEntries[i].getEntryDetailId()); log.debug("Summary: " + calEntries[i].getSummary()); log.debug("Start: " + calEntries[i].getStartDateTime().getTime()); log.debug("End: " + calEntries[i].getEndDateTime().getTime()); log.debug("Details: " + calEntries[i].getDetail()); if (calEntries[i].isAllDayEventFlag()) { log.debug("isAllDay"); Calendar endEvent = (Calendar) calEntries[i].getStartDateTime().clone(); endEvent.roll(Calendar.DATE, true); VEvent iCal4jEvent = new VEvent(new Date(calEntries[i].getStartDateTime().getTime()), new Date(endEvent.getTime()), calEntries[i].getSummary()); iCal4j.getComponents().add(iCal4jEvent); } else { DateTime start = new DateTime(calEntries[i].getStartDateTime().getTime()); DateTime end = new DateTime(calEntries[i].getStartDateTime().getTime()); VEvent iCal4jEvent = new VEvent(start, end, calEntries[i].getSummary()); iCal4j.getComponents().add(iCal4jEvent); } } } else { log.info("No calendar entries found for this user"); } log.debug(iCal4j.toString()); return iCal4j; } catch (MalformedURLException mue) { throw new CalendarException("Problem with Calendar URL"); } catch (ContextException cx) { throw new CalendarException("Problem connecting to calendar"); } catch (RemoteException re) { throw new CalendarException("Problem getting data from calendar"); } catch (com.webct.platform.sdk.calendar.exceptions.CalendarException ce) { throw new CalendarException("Problem with data from calendar"); } }