List of usage examples for java.math BigDecimal BigDecimal
public BigDecimal(long val)
From source file:com.yahoo.parsec.clients.ParsecClientProfilingLogUtil.java
/** * log remote profiling log.//w ww.j a v a 2s . c o m * * @param request ning http request * @param response ning http response * @param requestStatus request status * @param progress parsec async progress do * @param msgMap additional log msg in key=String, value=String format */ public static void logRemoteRequest(final Request request, final Response response, final String requestStatus, final ParsecAsyncProgress progress, final Map<String, String> msgMap) { if (!PROF_LOGGER.isTraceEnabled()) { return; } // // prepare log data // long now = System.currentTimeMillis(); BigDecimal timeInSecond = new BigDecimal(now).divide(BigDecimal.valueOf(DateUtils.MILLIS_PER_SECOND)); String contentLength = ""; String origin = ""; int respCode = -1; String reqUrl = request.getUri().toUrl(); String reqMethod = request.getMethod(); String reqHostHeader = request.getHeaders().getFirstValue(ParsecClientDefine.HEADER_HOST); if (response != null) { contentLength = response.getHeader(ParsecClientDefine.HEADER_CONTENT_LENGTH); respCode = response.getStatusCode(); } try { String executeInfo = OBJECT_MAPPER.writeValueAsString(progress); // // FIXME: should implement a servlet filter to set $_SERVER['REQUEST_URI'] // String srcUrl = ""; StringBuilder stringBuilder = new StringBuilder().append("time=").append(timeInSecond).append(", ") .append("req_url=").append(reqUrl).append(", ").append("req_host_header=").append(reqHostHeader) .append(", ").append("req_method=").append(reqMethod).append(", ").append("exec_info=") .append(executeInfo).append(", ").append("resp_code=").append(respCode).append(", ") .append("src_url=").append(srcUrl).append(", ").append("req_status=").append(requestStatus) .append(", ").append("content_length=").append(contentLength).append(", ").append("origin=") .append(origin).append(", "); if (msgMap != null) { for (Map.Entry<String, String> entry : msgMap.entrySet()) { stringBuilder.append(entry.getKey()).append("=").append(entry.getValue()).append(", "); } } String logMsg = stringBuilder.toString(); //logging PROF_LOGGER.trace(logMsg); } catch (JsonProcessingException e) { throw new RuntimeException(e); } }
From source file:ch.rasc.extclassgenerator.validation.RangeValidation.java
public RangeValidation(String field, Long min, Long max) { this(field, min != null ? new BigDecimal(min) : null, max != null ? new BigDecimal(max) : null); }
From source file:org.jongo.mocks.UserMock.java
public static UserMock getRandomInstance() { final UserMock instance = new UserMock(); instance.name = new BigInteger(100, random).toString(32); instance.age = 1 + (int) (Math.random() * ((100 - 1) + 1)); instance.birthday = dateFTR.parseDateTime(getRandomBirthDate()); instance.lastupdate = new DateTime(); instance.credit = new BigDecimal(random.nextDouble()); return instance; }
From source file:ch.algotrader.util.RoundUtil.java
public static BigDecimal getBigDecimal(double value) { if (Double.isNaN(value) || Double.isInfinite(value)) { return null; } else {/*from w ww.java2 s . c o m*/ BigDecimal decimal = new BigDecimal(value); CommonConfig commonConfig = ConfigLocator.instance().getCommonConfig(); return decimal.setScale(commonConfig.getPortfolioDigits(), BigDecimal.ROUND_HALF_UP); } }
From source file:com.trenako.format.GaugeFormatter.java
@Override public String print(Number object, Locale locale) { BigDecimal number = new BigDecimal((Integer) object).divide(Scale.GAUGE_FACTOR); return super.print(number, locale); }
From source file:com.trenako.format.RatioFormatter.java
@Override public String print(Number object, Locale locale) { BigDecimal number = new BigDecimal((Integer) object).divide(Scale.RATIO_FACTOR); return super.print(number, locale); }
From source file:org.opencredo.cloud.storage.samples.quote.QuoteService.java
public void lookupQuote(Message<String> tickerMessage) { BigDecimal price = new BigDecimal(new Random().nextDouble() * 100); LOG.info("Quote Update... {}: {}", tickerMessage.getPayload(), price.setScale(2, RoundingMode.HALF_EVEN)); }
From source file:com.jeans.iservlet.resource.SoftwareResource.java
protected SoftwareResource() { super();/*from w w w. j a v a2 s.co m*/ this.companyId = 0; this.catalog = 0; this.vendor = null; this.modelOrVersion = null; this.assetUsage = null; this.purchaseTime = null; this.quantity = 0; this.cost = new BigDecimal(0.0); this.state = 0; this.comment = null; this.softwareType = 0; this.license = null; this.expiredTime = null; }
From source file:calendar.services.transformers.EntryToDayTransformer.java
@Override public DaySummary transform(List<Entry> entryList) { BigDecimal total = new BigDecimal(0); Calendar cal = Calendar.getInstance(); cal.setTime(this.date); if (!entryList.isEmpty()) { daySummary.setEntries(entryList); total = entryList.stream().map((x) -> x.getHours()).reduce((x, y) -> x.add(y)).get(); }// w ww .j av a 2s .c o m daySummary.setDay(cal.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.SHORT, Locale.UK)); daySummary.setTotal(total); return daySummary; }
From source file:com.taobao.ad.jpa.test.ReportJobTest.java
@Test public void testInsertReportJob_save() { ReportJobDO job = new ReportJobDO(); job.setJobNum(2L);/*from www. jav a 2 s.c o m*/ job.setSuccessNum(2L); job.setErrorNum(2L); job.setRt(new BigDecimal(22.3)); job.setReportTime(new Date()); reportJobBO.saveOrUpdateReportJob(job); }