List of usage examples for org.apache.commons.lang.math NumberUtils toLong
public static long toLong(String str, long defaultValue)
Convert a String to a long, returning a default value if the conversion fails.
If the string is null, the default value is returned.
NumberUtils.toLong(null, 1L) = 1L NumberUtils.toLong("", 1L) = 1L NumberUtils.toLong("1", 0L) = 1L From source file:com.cloud.utils.NumbersUtil.java
public static long parseLong(String s, long defaultValue) { return NumberUtils.toLong(s, defaultValue); }
From source file:com.zb.app.external.wechat.request.WeixinRequest.java
/** * ??/* ww w . j a v a 2 s. c om*/ * * @param datas */ private void init(Map<String, String> datas) { msgType = datas.get("MsgType"); toUserName = datas.get("ToUserName"); fromUserName = datas.get("FromUserName"); long ct = NumberUtils.toLong(datas.get("CreateTime"), 0); if (ct > 0) { createTime = ct; } long mid = NumberUtils.toLong(datas.get("MsgId"), 0); if (mid > 0) { msgId = mid; } }
From source file:com.moreopen.monitor.console.utils.AppSettings.java
public Long getLong(String key) { return NumberUtils.toLong(this.getSetting(key), 0); }
From source file:com.alibaba.otter.manager.web.home.module.screen.CheckDelayStat.java
private static Map<Long, Long> parseAlert(String alert) { if (alert == null) { return null; }// w w w . j av a 2 s.c o m Map<Long, Long> alertMap = new HashMap<Long, Long>(); String[] alerts = alert.split(","); for (int i = 0; i < alerts.length; i++) { String[] ncidAlert = alerts[i].split("-"); alertMap.put(NumberUtils.toLong(ncidAlert[0], 0), NumberUtils.toLong(ncidAlert[1], 0)); if (logger.isInfoEnabled()) { logger.info(ncidAlert[0] + " : " + ncidAlert[1]); } } return alertMap; }
From source file:mobile.service.FriendService.java
/** * ???// w ww .ja v a 2 s .c o m * * @param messageId ??Id * @return */ public static ServiceResult acceptInvite(Long messageId) { models.User me = models.User.getFromSession(Context.current().session()); Message message = Message.queryById(messageId); if (null == message || message.msgType != MsgType.ADD_FRIENDS || !Objects.equals(message.consumeOnly, me.id.toString())) { return ServiceResult.error("100005", "?messageId = " + messageId); } models.User senderUser = models.User.findById(NumberUtils.toLong(message.senderOnly, -1)); if (null == senderUser) { LOGGER.error("invalid senderId. message.content = " + message.content); return ServiceResult.error("100001", ""); } Boolean flag = FriendsService.addFriend(me, senderUser); // ? Boolean flag2 = FriendsService.addFriend(senderUser, me); // ? MessageService.pushMsgAgreeFriends(me, senderUser); MessageService.handlerMessage(messageId); // ??? if (flag && flag2) { return ServiceResult.success(); } else { return ServiceResult.error("287001", "??"); } }
From source file:com.google.code.profiling.filters.ProfilingTimerFilter.java
public void init(FilterConfig filterConfig) throws ServletException { long minTime = NumberUtils.toLong(filterConfig.getInitParameter(MIN_TIME_PARAM), 0); this.utilTimerStack = new UtilTimerStack(minTime); }
From source file:com.netsteadfast.greenstep.action.CommonUploadAction.java
public String getUploadMultipartMaxSizeLabel() { Long size = NumberUtils.toLong(this.getUploadMultipartMaxSize(), 0L); if (size < 1024) { return size + " bytes"; }/*w ww . j av a 2 s .c om*/ size = size / 1024; if (size < 1024) { return size + " KB"; } return (size / 1024) + " MB"; }
From source file:com.google.code.profiling.filters.ProfilingMemoryFilter.java
public void init(FilterConfig filterConfig) throws ServletException { long minMemory = NumberUtils.toLong(filterConfig.getInitParameter(MIN_MEMORY_PARAM), 0); this.utilMemoryStack = new UtilMemoryStack(minMemory); }
From source file:com.moviejukebox.tools.TraktTV.java
public TraktTV initialize() { if (traktTvApi != null) { // nothing to do if API already set return this; }/*from w w w .ja v a2 s . co m*/ final String clientId = PropertiesUtil.getProperty("API_KEY_TraktTV_ClientId"); final String secret = PropertiesUtil.getProperty("API_KEY_TraktTV_Secret"); try { LOG.trace("Initialize Trakt.TV API"); traktTvApi = new TraktTvApi(clientId, secret, YamjHttpClientBuilder.getHttpClient()); // set access token from properties Properties props = new Properties(); File propsFile = new File(PROPS_FILE); if (propsFile.exists()) { try (InputStream is = new FileInputStream(propsFile)) { props.load(is); traktTvApi.setAccessToken(props.getProperty(PROP_ACCESS_TOKEN)); refreshToken = props.getProperty(PROP_REFRESH_TOKEN); expirationDate = NumberUtils.toLong(props.getProperty(PROP_EXPIRATION_DATE), 0); // API is now initialized this.initialized = true; } catch (Exception e) { LOG.error("Failed to load Trakt.TV properties"); } } } catch (Exception ex) { LOG.error("Failed to initialize Trakt.TV API", ex); } return this; }
From source file:com.netsteadfast.greenstep.bsc.action.ScoreColorSaveOrUpdateAction.java
private void checkFields() throws ControllerException { this.getCheckFieldHandler() .add("score", BscNumberFieldCheckUtils.class, this.getText("MESSAGE.BSC_PROG001D0004Q_score")) .process().throwMessage();//w ww .j ava 2 s . c om this.getCheckFieldHandler() .single("score", (NumberUtils.toLong(this.getFields().get("score"), 0) < BscConstants.SCORE_COLOR_MIN_VALUE), this.getText("MESSAGE.BSC_PROG001D0004Q_score_msg1") + " " + BscConstants.SCORE_COLOR_MIN_VALUE) .single("score", (NumberUtils.toLong(this.getFields().get("score"), 0) > BscConstants.SCORE_COLOR_MAX_VALUE), this.getText("MESSAGE.BSC_PROG001D0004Q_score_msg2") + " " + BscConstants.SCORE_COLOR_MAX_VALUE) .throwMessage(); if (StringUtils.isBlank(this.getFields().get("bgColor")) || StringUtils.isBlank(this.getFields().get("fontColor"))) { super.throwMessage(this.getText("MESSAGE.BSC_PROG001D0004Q_bgColorfontColor_msg")); } }