List of usage examples for java.math BigInteger ZERO
BigInteger ZERO
To view the source code for java.math BigInteger ZERO.
Click Source Link
From source file:Main.java
/** * Java runtime 1.5 is inconsistent with its handling of days in Duration objects. * @param duration A duration object to be normalised * @return A day-normalised duration, i.e. all years and months converted to days, * e.g. 1Y 3M 3D => 458 days/* w w w .j av a 2s. c om*/ */ private static javax.xml.datatype.Duration normaliseDays(javax.xml.datatype.Duration duration) { final long DAYS_PER_MONTH = 30; final long DAYS_PER_YEAR = 365; BigInteger days = (BigInteger) duration.getField(DatatypeConstants.DAYS); BigInteger months = (BigInteger) duration.getField(DatatypeConstants.MONTHS); BigInteger years = (BigInteger) duration.getField(DatatypeConstants.YEARS); BigInteger normalisedDays = years.multiply(BigInteger.valueOf(DAYS_PER_YEAR)); normalisedDays = normalisedDays.add(months.multiply(BigInteger.valueOf(DAYS_PER_MONTH))); normalisedDays = normalisedDays.add(days); BigInteger hours = (BigInteger) duration.getField(DatatypeConstants.HOURS); BigInteger minutes = (BigInteger) duration.getField(DatatypeConstants.MINUTES); BigDecimal seconds = (BigDecimal) duration.getField(DatatypeConstants.SECONDS); boolean positive = duration.getSign() >= 0; return FACTORY.newDuration(positive, BigInteger.ZERO, BigInteger.ZERO, normalisedDays, hours, minutes, seconds); }
From source file:org.egov.pgr.service.dashboard.DashboardService.java
public Map<String, Object> topComplaints() { final DateTime currentDate = new DateTime(); final List<Object> dataHolderNumber = constructListOfMonthPlaceHolder(currentDate.minusMonths(5), currentDate.plusMonths(1), "MM"); final List<Object> dataHolderString = constructListOfMonthPlaceHolder(currentDate.minusMonths(5), currentDate.plusMonths(1), "MMM"); final List<Object[]> topFiveCompTypeData = dashboardRepository.fetchTopComplaintsBetween( startOfGivenDate(currentDate.minusMonths(5).withDayOfMonth(1)).toDate(), endOfGivenDate(currentDate).toDate()); final List<Object[]> topFiveCompTypeCurrentMonth = dashboardRepository .fetchTopComplaintsForCurrentMonthBetween( startOfGivenDate(currentDate.minusMonths(5).withDayOfMonth(1)).toDate(), endOfGivenDate(currentDate).toDate()); final Map<Object, Object> constructResultPlaceholder = new LinkedHashMap<Object, Object>(); final Map<Object, Object> actualdata = new LinkedHashMap<Object, Object>(); for (final Object complaintType : topFiveCompTypeCurrentMonth) for (final Object month : dataHolderNumber) constructResultPlaceholder.put(month + "-" + complaintType, BigInteger.ZERO); for (final Object[] top5CompType : topFiveCompTypeData) actualdata.put(top5CompType[0] + "-" + top5CompType[2], top5CompType[1]); final Map<Object, Object> newdata = new LinkedHashMap<Object, Object>(); for (final Object placeholderMapKey : constructResultPlaceholder.keySet()) if (actualdata.get(placeholderMapKey) == null) newdata.put(placeholderMapKey, BigInteger.ZERO); else/*from w ww .j a v a 2 s .com*/ newdata.put(placeholderMapKey, actualdata.get(placeholderMapKey)); final Map<String, Object> topFiveCompDataHolder = new LinkedHashMap<String, Object>(); final List<Object> dataHolder = new LinkedList<Object>(); final List<Object> compCount = new ArrayList<Object>(); final Iterator<Entry<Object, Object>> entries = newdata.entrySet().iterator(); int index = 0; while (entries.hasNext()) { final Map<String, Object> tmpdata = new LinkedHashMap<String, Object>(); final Entry<Object, Object> entry = entries.next(); if (index < 5) { compCount.add(entry.getValue()); index++; } else if (index == 5) { compCount.add(entry.getValue()); final String[] parts = entry.getKey().toString().split("-"); tmpdata.put("name", parts[1]); tmpdata.put("data", new LinkedList<Object>(compCount)); final HashMap<String, Object> ctypeCountMap = new LinkedHashMap<String, Object>(); ctypeCountMap.putAll(tmpdata); dataHolder.add(ctypeCountMap); index = 0; compCount.clear(); tmpdata.clear(); } } topFiveCompDataHolder.put("year", dataHolderString); topFiveCompDataHolder.put("series", dataHolder); return topFiveCompDataHolder; }
From source file:com.teamj.distribuidas.web.ExcursionUserBean.java
public void loadExcursionSelectedData(SelectEvent event) { this.excursionArticulos = ((Excursion) event.getObject()).getExcursionArticulos(); try {// w w w .ja v a2 s. c o m BeanUtils.copyProperties(this.excursion, this.excursionSelected); // FacesContext.getCurrentInstance().addMessage(null, msg); } catch (IllegalAccessException | InvocationTargetException ex) { Logger.getLogger(ExcursionUserBean.class.getName()).log(Level.SEVERE, null, ex); } this.totalArticulos = 0; this.subtotal = new BigDecimal(BigInteger.ZERO); this.derechoExcursionSeleccionada = BigDecimal.ZERO; if (this.excursionArticulosSelected != null) { this.excursionArticulosSelected.clear(); } }
From source file:com.sdcs.courierbooking.service.UserServiceImpl.java
@Override public String sendForgotPassword(String strcontact) { JSONObject responseJson = new JSONObject(); ResultSet previousPass = userDao.getPassword(strcontact); try {//from w w w . j a v a 2 s .co m if (previousPass != null && previousPass.next()) { String name = previousPass.getString("full_name"); String strEmail = previousPass.getString("email_address"); String passwordGot = previousPass.getString("access_key"); String mailBody = "<b>Dear Customer,</b>" + "<br>" + "<b><i> Thank you for choosing SDCS.</i></b>" + "<p> You have requested us for your forgot password and below are your credentials,</b>" + "<br>" + "<p> Username: " + strcontact + "</p> <br>" + "<p> Password: " + passwordGot + "</p> <br>" + "Thanks" + "<br>" + "SDCS Team" + "<br>" + "info@sdcs.me"; ; SdcsEmailComponent.sendMail(strEmail, "SDCS - Password Recovery", mailBody, BigInteger.ZERO); String strSmsText = "%20Dear%20" + name + ",%20Your%20registered%20password%20is%20" + passwordGot + ".%20Thanking%20you%20SDCS."; SdcsSMSComponent.sendSms(strcontact, strSmsText); responseJson.put("status", true); responseJson.put("phone", strcontact); previousPass.close(); } } catch (SQLException e) { responseJson.put("status", false); } return responseJson.toString(); // TODO Auto-generated method stub }
From source file:com.google.cloud.storage.spi.v1.HttpStorageRpc.java
private static Function<String, StorageObject> objectFromPrefix(final String bucket) { return new Function<String, StorageObject>() { @Override/*from w w w . ja v a 2 s. c o m*/ public StorageObject apply(String prefix) { return new StorageObject().set("isDirectory", true).setBucket(bucket).setName(prefix) .setSize(BigInteger.ZERO); } }; }
From source file:brut.androlib.res.decoder.ARSCDecoder.java
private ResConfigFlags readConfigFlags() throws IOException, AndrolibException { int size = mIn.readInt(); int read = 0; if (size < 28) { throw new AndrolibException("Config size < 28"); }/*from ww w. j a va 2 s . c o m*/ boolean isInvalid = false; short mcc = mIn.readShort(); short mnc = mIn.readShort(); char[] language = this.unpackLanguageOrRegion(mIn.readByte(), mIn.readByte(), 'a'); char[] country = this.unpackLanguageOrRegion(mIn.readByte(), mIn.readByte(), '0'); byte orientation = mIn.readByte(); byte touchscreen = mIn.readByte(); int density = mIn.readUnsignedShort(); byte keyboard = mIn.readByte(); byte navigation = mIn.readByte(); byte inputFlags = mIn.readByte(); /* inputPad0 */mIn.skipBytes(1); short screenWidth = mIn.readShort(); short screenHeight = mIn.readShort(); short sdkVersion = mIn.readShort(); /* minorVersion, now must always be 0 */mIn.skipBytes(2); byte screenLayout = 0; byte uiMode = 0; short smallestScreenWidthDp = 0; if (size >= 32) { screenLayout = mIn.readByte(); uiMode = mIn.readByte(); smallestScreenWidthDp = mIn.readShort(); read = 32; } short screenWidthDp = 0; short screenHeightDp = 0; if (size >= 36) { screenWidthDp = mIn.readShort(); screenHeightDp = mIn.readShort(); read = 36; } char[] localeScript = null; char[] localeVariant = null; if (size >= 48) { localeScript = readScriptOrVariantChar(4).toCharArray(); localeVariant = readScriptOrVariantChar(8).toCharArray(); read = 48; } byte screenLayout2 = 0; if (size >= 52) { screenLayout2 = mIn.readByte(); mIn.skipBytes(3); // reserved padding read = 52; } int exceedingSize = size - KNOWN_CONFIG_BYTES; if (exceedingSize > 0) { byte[] buf = new byte[exceedingSize]; read += exceedingSize; mIn.readFully(buf); BigInteger exceedingBI = new BigInteger(1, buf); if (exceedingBI.equals(BigInteger.ZERO)) { LOGGER.fine(String.format( "Config flags size > %d, but exceeding bytes are all zero, so it should be ok.", KNOWN_CONFIG_BYTES)); } else { LOGGER.warning(String.format("Config flags size > %d. Exceeding bytes: 0x%X.", KNOWN_CONFIG_BYTES, exceedingBI)); isInvalid = true; } } int remainingSize = size - read; if (remainingSize > 0) { mIn.skipBytes(remainingSize); } return new ResConfigFlags(mcc, mnc, language, country, orientation, touchscreen, density, keyboard, navigation, inputFlags, screenWidth, screenHeight, sdkVersion, screenLayout, uiMode, smallestScreenWidthDp, screenWidthDp, screenHeightDp, localeScript, localeVariant, screenLayout2, isInvalid); }
From source file:org.openhim.mediator.denormalization.ATNAAuditingActor.java
protected String generateForPNRReceived(ATNAAudit audit) throws JAXBException { AuditMessage res = new AuditMessage(); EventIdentificationType eid = new EventIdentificationType(); eid.setEventID(ATNAUtil.buildCodedValueType("DCM", "110107", "Import")); eid.setEventActionCode("C"); eid.setEventDateTime(ATNAUtil.newXMLGregorianCalendar()); eid.getEventTypeCode().add(//from w w w . ja va2s . c om ATNAUtil.buildCodedValueType("IHE Transactions", "ITI-41", "Provide and Register Document Set-b")); eid.setEventOutcomeIndicator(audit.getOutcome() ? BigInteger.ZERO : new BigInteger("4")); res.setEventIdentification(eid); res.getActiveParticipant().add(ATNAUtil.buildActiveParticipant(ATNAUtil.WSA_REPLYTO_ANON, "client", true, audit.getSourceIP(), (short) 2, "DCM", "110153", "Source")); res.getActiveParticipant().add(ATNAUtil.buildActiveParticipant(ATNAUtil.WSA_REPLYTO_ANON, ATNAUtil.getProcessID(), false, ATNAUtil.getHostIP(), (short) 2, "DCM", "110152", "Destination")); res.getAuditSourceIdentification().add(ATNAUtil.buildAuditSource("openhim")); // Only one is allowed Identifier id = audit.getParticipantIdentifiers().get(0); if (id != null) { res.getParticipantObjectIdentification().add(ATNAUtil.buildParticipantObjectIdentificationType( id.toCX(), (short) 1, (short) 1, "RFC-3881", "2", "PatientNumber", null)); } List<ATNAUtil.ParticipantObjectDetail> pod = new ArrayList<>(); pod.add(new ATNAUtil.ParticipantObjectDetail("QueryEncoding", "UTF-8".getBytes())); if (audit.getHomeCommunityId() != null) pod.add(new ATNAUtil.ParticipantObjectDetail("urn:ihe:iti:xca:2010:homeCommunityId", audit.getHomeCommunityId().getBytes())); res.getParticipantObjectIdentification() .add(ATNAUtil.buildParticipantObjectIdentificationType(audit.getUniqueId(), (short) 2, (short) 20, "IHE XDS Metadata", "urn:uuid:a54d6aa5-d40d-43f9-88c5-b4633d873bdd", "submission set classificationNode", audit.getMessage(), pod)); return ATNAUtil.marshallATNAObject(res); }
From source file:co.rsk.blockchain.utils.BlockGenerator.java
public static Block createChildBlock(Block parent, List<Transaction> txs, byte[] stateRoot, byte[] coinbase) { Bloom logBloom = new Bloom(); if (txs == null) txs = new ArrayList<>(); return new Block(parent.getHash(), // parent hash EMPTY_LIST_HASH, // uncle hash coinbase, // coinbase logBloom.getData(), // logs bloom parent.getDifficulty(), // difficulty parent.getNumber() + 1, parent.getGasLimit(), parent.getGasUsed(), parent.getTimestamp() + ++count, EMPTY_BYTE_ARRAY, // extraData EMPTY_BYTE_ARRAY, // mixHash BigInteger.ZERO.toByteArray(), // provisory nonce EMPTY_TRIE_HASH, // receipts root BlockChainImpl.calcTxTrie(txs), // transaction root stateRoot, //EMPTY_TRIE_HASH, // state root txs, // transaction list null, // uncle list null);//from w w w . jav a2 s . c o m }
From source file:burstcoin.observer.service.AssetService.java
private String convertPrice(String priceString, int decimals) { BigInteger price = new BigInteger(priceString); BigInteger amount = price.multiply(new BigInteger("" + (long) Math.pow(10, decimals))); String negative = ""; String afterComma = ""; String fractionalPart = amount.mod(new BigInteger("100000000")).toString(); amount = amount.divide(new BigInteger("100000000")); if (amount.compareTo(BigInteger.ZERO) < 0) { amount = amount.abs();//from w ww .j a va 2 s . c om negative = "-"; } if (!fractionalPart.equals("0")) { afterComma = "."; for (int i = fractionalPart.length(); i < 8; i++) { afterComma += "0"; } afterComma += fractionalPart.replace("0+$", ""); } String result = negative + amount + afterComma; while (result.lastIndexOf("0") == result.length() - 1 && result.contains(".")) { result = result.substring(0, result.length() - 1); } if (result.lastIndexOf(".") == result.length() - 1) { result = result.substring(0, result.length() - 1); } return result; }
From source file:org.kuali.kra.iacuc.committee.print.IacucScheduleXmlStream.java
public ScheduleType getSchedule(CommitteeScheduleBase committeeSchedule) { ScheduleType schedule = ScheduleType.Factory.newInstance(); setScheduleMasterData(committeeSchedule, schedule.addNewScheduleMasterData()); ScheduleSummaryType prevSchedule = schedule.addNewPreviousSchedule(); setPreviousSchedule(committeeSchedule, prevSchedule.addNewScheduleMasterData()); ScheduleSummaryType nextScheduleType = schedule.addNewNextSchedule(); setNextSchedule(committeeSchedule, nextScheduleType.addNewScheduleMasterData()); //For some reason Spring isn't always populating this service. SIGH! if (getPrintXmlUtilService() == null) { printXmlUtilService = KcServiceLocator.getService(IacucPrintXmlUtilService.class); }/* w w w . j a va 2 s. c o m*/ getPrintXmlUtilService().setMinutes(committeeSchedule, schedule); setAttendance(committeeSchedule, schedule); committeeSchedule.refreshReferenceObject("protocolSubmissions"); List<org.kuali.kra.protocol.actions.submit.ProtocolSubmissionBase> submissions = committeeSchedule .getLatestProtocolSubmissions(); for (org.kuali.kra.protocol.actions.submit.ProtocolSubmissionBase protocolSubmission : submissions) { ProtocolSubmissionType protocolSubmissionType = schedule.addNewProtocolSubmission(); SubmissionDetailsType protocolSubmissionDetail = protocolSubmissionType.addNewSubmissionDetails(); ProtocolSummaryType protocolSummary = protocolSubmissionType.addNewProtocolSummary(); ProtocolMasterDataType protocolMaster = protocolSummary.addNewProtocolMasterData(); String followUpAction = null; String actionTypeCode = null; ProtocolBase protocol = protocolSubmission.getProtocol(); String submissionStatus = protocol.getProtocolSubmission().getSubmissionStatusCode(); List<ProtocolActionBase> protocolActions = protocolSubmission.getProtocol().getProtocolActions(); for (ProtocolActionBase protocolAction : protocolActions) { actionTypeCode = protocolAction.getProtocolActionTypeCode(); if (actionTypeCode.equals(EXPEDIT_ACTION_TYPE_CODE) || actionTypeCode.equals(EXEMPT_ACTION_TYPE_CODE)) { if (protocolAction.getFollowupActionCode() != null && protocolAction.getFollowupActionCode().equals(FOLLOW_UP_ACTION_CODE)) { followUpAction = protocolAction.getFollowupActionCode(); } break; } } if ((actionTypeCode.equals(EXPEDIT_ACTION_TYPE_CODE) || actionTypeCode.equals(EXEMPT_ACTION_TYPE_CODE)) && followUpAction == null) { continue; } protocolMaster.setProtocolNumber(protocol.getProtocolNumber()); protocolMaster.setSequenceNumber(new BigInteger(String.valueOf(protocol.getSequenceNumber()))); protocolMaster.setProtocolTitle(protocol.getTitle()); protocolMaster.setProtocolStatusCode(new BigInteger(String.valueOf(protocol.getProtocolStatusCode()))); protocolMaster.setProtocolStatusDesc(protocol.getProtocolStatus().getDescription()); protocolMaster.setProtocolTypeCode(new BigInteger(String.valueOf(protocol.getProtocolTypeCode()))); protocolMaster.setProtocolTypeDesc(protocol.getProtocolType().getDescription()); if (protocol.getDescription() != null) { protocolMaster.setProtocolDescription(protocol.getDescription()); } if (protocol.getApprovalDate() != null) { protocolMaster.setApprovalDate(getDateTimeService().getCalendar(protocol.getApprovalDate())); } if (protocol.getExpirationDate() != null) { protocolMaster.setExpirationDate(getDateTimeService().getCalendar(protocol.getExpirationDate())); } if (protocol.getFdaApplicationNumber() != null) { protocolMaster.setFdaApplicationNumber(protocol.getFdaApplicationNumber()); } if (protocol.getReferenceNumber1() != null) { protocolMaster.setRefNumber1(protocol.getReferenceNumber1()); } if (protocol.getReferenceNumber2() != null) { protocolMaster.setRefNumber2(protocol.getReferenceNumber2()); } protocolSubmissionDetail.setProtocolNumber(protocolSubmission.getProtocolNumber()); if (protocolSubmission.getProtocolSubmissionType() != null) { protocolSubmissionDetail .setSubmissionTypeDesc(protocolSubmission.getProtocolSubmissionType().getDescription()); } if (protocolSubmission.getProtocolReviewTypeCode() != null) { protocolSubmissionDetail .setProtocolReviewTypeCode(new BigInteger(protocolSubmission.getProtocolReviewTypeCode())); } if (protocolSubmission.getProtocolReviewType() != null) { protocolSubmissionDetail .setProtocolReviewTypeDesc(protocolSubmission.getProtocolReviewType().getDescription()); } if (protocolSubmission.getSubmissionTypeCode() != null) { protocolSubmissionDetail.setSubmissionTypeCode( new BigInteger(String.valueOf(protocolSubmission.getSubmissionTypeCode()))); } if (protocolSubmission.getProtocolSubmissionType() != null) { protocolSubmissionDetail .setSubmissionTypeDesc(protocolSubmission.getProtocolSubmissionType().getDescription()); } if (protocolSubmission.getSubmissionNumber() != null) { protocolSubmissionDetail.setSubmissionNumber( new BigInteger(String.valueOf(protocolSubmission.getSubmissionNumber()))); } if (protocolSubmission.getSubmissionStatusCode() != null) { protocolSubmissionDetail.setSubmissionStatusCode( new BigInteger(String.valueOf(protocolSubmission.getSubmissionStatusCode()))); } if (protocolSubmission.getSubmissionStatus() != null) { protocolSubmissionDetail .setSubmissionStatusDesc(protocolSubmission.getSubmissionStatus().getDescription()); } if (protocolSubmission.getSubmissionTypeQualifierCode() != null) { protocolSubmissionDetail.setSubmissionTypeQualifierCode( new BigInteger(protocolSubmission.getSubmissionTypeQualifierCode())); } if (protocolSubmission.getProtocolSubmissionQualifierType() != null) { protocolSubmissionDetail.setSubmissionTypeQualifierDesc( protocolSubmission.getProtocolSubmissionQualifierType().getDescription()); } if (protocolSubmission.getYesVoteCount() != null) { protocolSubmissionDetail.setYesVote(BigInteger.valueOf(protocolSubmission.getYesVoteCount())); } else { protocolSubmissionDetail.setYesVote(BigInteger.ZERO); } if (protocolSubmission.getNoVoteCount() != null) { protocolSubmissionDetail.setNoVote(BigInteger.valueOf(protocolSubmission.getNoVoteCount())); } else { protocolSubmissionDetail.setNoVote(BigInteger.ZERO); } if (protocolSubmission.getAbstainerCount() != null) { protocolSubmissionDetail .setAbstainerCount(BigInteger.valueOf(protocolSubmission.getAbstainerCount())); } else { protocolSubmissionDetail.setAbstainerCount(BigInteger.ZERO); } protocolSubmissionDetail.setVotingComments(protocolSubmission.getVotingComments()); setProtocolSubmissionAction(protocolSubmission, protocolSubmissionDetail); if (protocolSubmission.getSubmissionDate() != null) { protocolSubmissionDetail.setSubmissionDate( getDateTimeService().getCalendar(protocolSubmission.getSubmissionDate())); } setSubmissionCheckListinfo(protocolSubmission, protocolSubmissionDetail); setProtocolSubmissionReviewers(protocolSubmission, protocolSubmissionDetail); List<ProtocolPersonBase> protocolPersons = protocolSubmission.getProtocol().getProtocolPersons(); for (ProtocolPersonBase protocolPerson : protocolPersons) { if (protocolPerson.getProtocolPersonRoleId() .equals(ProtocolPersonRoleBase.ROLE_PRINCIPAL_INVESTIGATOR) || protocolPerson.getProtocolPersonRoleId() .equals(ProtocolPersonRoleBase.ROLE_CO_INVESTIGATOR)) { InvestigatorType investigator = protocolSummary.addNewInvestigator(); getPrintXmlUtilService().setPersonRolodexType(protocolPerson, investigator.addNewPerson()); if (protocolPerson.getProtocolPersonRoleId() .equals(ProtocolPersonRoleBase.ROLE_PRINCIPAL_INVESTIGATOR)) { investigator.setPIFlag(true); } } } List<ProtocolFundingSourceBase> vecFundingSource = protocol.getProtocolFundingSources(); int fundingSourceTypeCode; String fundingSourceName, fundingSourceCode; for (ProtocolFundingSourceBase protocolFundingSourceBean : vecFundingSource) { protocolFundingSourceBean.refreshNonUpdateableReferences(); FundingSourceType fundingSource = protocolSummary.addNewFundingSource(); fundingSourceCode = protocolFundingSourceBean.getFundingSourceNumber(); fundingSourceTypeCode = Integer.valueOf(protocolFundingSourceBean.getFundingSourceTypeCode()); fundingSourceName = getFundingSourceNameForType(fundingSourceTypeCode, fundingSourceCode); fundingSource.setFundingSourceName(fundingSourceName); if (protocolFundingSourceBean.getFundingSourceType() != null) { fundingSource.setTypeOfFundingSource( protocolFundingSourceBean.getFundingSourceType().getDescription()); } } getPrintXmlUtilService().setProcotolMinutes(committeeSchedule, protocolSubmission, protocolSubmissionType); setOtherActionItems(committeeSchedule, schedule); } return schedule; }