⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 valueutils.java

📁 梦界家园程序开发基底框架
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
		DecimalFormat formatter = new DecimalFormat(pattern);
		value = formatter.format(src);

		if (value == null) {
			throw new Exception("format error = " + src);
		}

		return value;
	}

	/**
	 * 抣傪丄偦偺傑傑僐僺乕偟傑偡丅<br>
	 *
	 * @param from 僐僺乕尦偺抣傪帩偮僆僽僕僃僋僩
	 * @param to 僐僺乕愭僆僽僕僃僋僩
	 * @param name 抣傪庢摼丒愝掕偡傞柤慜
	 * @return 抣
	 * @exception Exception 壗偐傜偺僄儔乕丅徻嵶儊僢僙乕僕偵偼 name 偑丄尨場偵偼尨場偲側偭偨椺奜偑愝掕偝傟偰偄傑偡丅
	 */
	public static final Object objectToObject(Object from, Object to, String name) throws Exception {
		Object value = getObject(from, name);
		setObject(to, name, value);
		return value;
	}

	/**
	 * 抣傪丄偦偺傑傑僐僺乕偟傑偡丅<br>
	 * 僐僺乕尦偺抣偑 null 偺応崌偼丄defaultValue 傪僐僺乕愭偵愝掕偟傑偡丅
	 *
	 * @param from 僐僺乕尦偺抣傪帩偮僆僽僕僃僋僩
	 * @param to 僐僺乕愭僆僽僕僃僋僩
	 * @param name 抣傪庢摼丒愝掕偡傞柤慜
	 * @param defaultValue 僨僼僅儖僩抣
	 * @return 抣
	 * @exception Exception 壗偐傜偺僄儔乕丅徻嵶儊僢僙乕僕偵偼 name 偑丄尨場偵偼尨場偲側偭偨椺奜偑愝掕偝傟偰偄傑偡丅
	 */
	public static final Object objectToObject(Object from, Object to, String name, Object defaultValue) throws Exception {
		Object value = getObject(from, name);
		if (value == null) {
			value = defaultValue;
		}
		setObject(to, name, value);
		return value;
	}

	/**
	 * String 偺抣傪丄偦偺傑傑僐僺乕偟傑偡丅<br>
	 *
	 * @param from 僐僺乕尦偺抣傪帩偮僆僽僕僃僋僩
	 * @param to 僐僺乕愭僆僽僕僃僋僩
	 * @param name 抣傪庢摼丒愝掕偡傞柤慜
	 * @return 抣
	 * @exception Exception 壗偐傜偺僄儔乕丅徻嵶儊僢僙乕僕偵偼 name 偑丄尨場偵偼尨場偲側偭偨椺奜偑愝掕偝傟偰偄傑偡丅
	 */
	public static final String stringToString(Object from, Object to, String name) throws Exception {
		String value = (String) getObject(from, name);
		setObject(to, name, value);
		return value;
	}

	/**
	 * String 偺抣傪丄Date 偵曄姺偟偰僐僺乕偟傑偡丅<br>
	 *
	 * @param from 僐僺乕尦偺抣傪帩偮僆僽僕僃僋僩
	 * @param to 僐僺乕愭僆僽僕僃僋僩
	 * @param name 抣傪庢摼丒愝掕偡傞柤慜
	 * @return 曄姺屻偺抣
	 * @exception Exception 壗偐傜偺僄儔乕丅徻嵶儊僢僙乕僕偵偼 name 偑丄尨場偵偼尨場偲側偭偨椺奜偑愝掕偝傟偰偄傑偡丅
	 */
	public static final Date stringToDate(Object from, Object to, String name) throws Exception {
		String src = (String) getObject(from, name);
		Date value = toDate(DATE_PATTERN, src);
		setObject(to, name, value);
		return value;
	}

	/**
	 * String 偺抣傪丄java.sql.Date 偵曄姺偟偰僐僺乕偟傑偡丅<br>
	 *
	 * @param from 僐僺乕尦偺抣傪帩偮僆僽僕僃僋僩
	 * @param to 僐僺乕愭僆僽僕僃僋僩
	 * @param name 抣傪庢摼丒愝掕偡傞柤慜
	 * @return 曄姺屻偺抣
	 * @exception Exception 壗偐傜偺僄儔乕丅徻嵶儊僢僙乕僕偵偼 name 偑丄尨場偵偼尨場偲側偭偨椺奜偑愝掕偝傟偰偄傑偡丅
	 */
	public static final java.sql.Date stringToSqlDate(Object from, Object to, String name) throws Exception {
		String src = (String) getObject(from, name);
		java.sql.Date value = toSqlDate(DATE_PATTERN, src);
		setObject(to, name, value);
		return value;
	}

	/**
	 * String 偺抣傪丄java.sql.Time 偵曄姺偟偰僐僺乕偟傑偡丅<br>
	 *
	 * @param from 僐僺乕尦偺抣傪帩偮僆僽僕僃僋僩
	 * @param to 僐僺乕愭僆僽僕僃僋僩
	 * @param name 抣傪庢摼丒愝掕偡傞柤慜
	 * @return 曄姺屻偺抣
	 * @exception Exception 壗偐傜偺僄儔乕丅徻嵶儊僢僙乕僕偵偼 name 偑丄尨場偵偼尨場偲側偭偨椺奜偑愝掕偝傟偰偄傑偡丅
	 */
	public static final java.sql.Time stringToSqlTime(Object from, Object to, String name) throws Exception {
		String src = (String) getObject(from, name);
		java.sql.Time value = toSqlTime(DATE_PATTERN, src);
		setObject(to, name, value);
		return value;
	}

	/**
	 * String 偺抣傪丄java.sql.Timestamp 偵曄姺偟偰僐僺乕偟傑偡丅<br>
	 *
	 * @param from 僐僺乕尦偺抣傪帩偮僆僽僕僃僋僩
	 * @param to 僐僺乕愭僆僽僕僃僋僩
	 * @param name 抣傪庢摼丒愝掕偡傞柤慜
	 * @return 曄姺屻偺抣
	 * @exception Exception 壗偐傜偺僄儔乕丅徻嵶儊僢僙乕僕偵偼 name 偑丄尨場偵偼尨場偲側偭偨椺奜偑愝掕偝傟偰偄傑偡丅
	 */
	public static final java.sql.Timestamp stringToSqlTimestamp(Object from, Object to, String name) throws Exception {
		String src = (String) getObject(from, name);
		java.sql.Timestamp value = toSqlTimestamp(DATE_PATTERN, src);
		setObject(to, name, value);
		return value;
	}

	/**
	 * String 偺抣傪丄BigDecimal 偵曄姺偟偰僐僺乕偟傑偡丅<br>
	 *
	 * @param from 僐僺乕尦偺抣傪帩偮僆僽僕僃僋僩
	 * @param to 僐僺乕愭僆僽僕僃僋僩
	 * @param name 抣傪庢摼丒愝掕偡傞柤慜
	 * @return 曄姺屻偺抣
	 * @exception Exception 壗偐傜偺僄儔乕丅徻嵶儊僢僙乕僕偵偼 name 偑丄尨場偵偼尨場偲側偭偨椺奜偑愝掕偝傟偰偄傑偡丅
	 */
	public static final BigDecimal stringToBigDecimal(Object from, Object to, String name) throws Exception {
		return stringToBigDecimal(from, to, name, DECIMAL_PATTERN);
	}

	/**
	 * String 偺抣傪丄BigDecimal 偵曄姺偟偰僐僺乕偟傑偡丅<br>
	 *
	 * @param from 僐僺乕尦偺抣傪帩偮僆僽僕僃僋僩
	 * @param to 僐僺乕愭僆僽僕僃僋僩
	 * @param name 抣傪庢摼丒愝掕偡傞柤慜
	 * @param pattern 暥帤楍傪悢抣壔偡傞僷僞乕儞
	 * @return 曄姺屻偺抣
	 * @exception Exception 壗偐傜偺僄儔乕丅徻嵶儊僢僙乕僕偵偼 name 偑丄尨場偵偼尨場偲側偭偨椺奜偑愝掕偝傟偰偄傑偡丅
	 */
	public static final BigDecimal stringToBigDecimal(Object from, Object to, String name, String[] pattern) throws Exception {
		String src = (String) getObject(from, name);
		BigDecimal value = toBigDecimal(pattern, src);
		setObject(to, name, value);
		return value;
	}

	/**
	 * Date 偺抣傪丄String 偵曄姺偟偰僐僺乕偟傑偡丅<br>
	 * 偙偺儊僜僢僪偱偼丄擭寧擔傪曄姺偟傑偡丅
	 *
	 * @param from 僐僺乕尦偺抣傪帩偮僆僽僕僃僋僩
	 * @param to 僐僺乕愭僆僽僕僃僋僩
	 * @param name 抣傪庢摼丒愝掕偡傞柤慜
	 * @return 曄姺屻偺抣
	 * @exception Exception 壗偐傜偺僄儔乕丅徻嵶儊僢僙乕僕偵偼 name 偑丄尨場偵偼尨場偲側偭偨椺奜偑愝掕偝傟偰偄傑偡丅
	 */
	public static final String dateToString(Object from, Object to, String name) throws Exception {
		Date src = (Date) getObject(from, name);
		String value = toString(DATE_PATTERN[0], src);
		setObject(to, name, value);
		return value;
	}

	/**
	 * Date 偺抣傪丄String 偵曄姺偟偰僐僺乕偟傑偡丅<br>
	 * 偙偺儊僜僢僪偱偼丄擭寧擔帪暘昩傪曄姺偟傑偡丅
	 *
	 * @param from 僐僺乕尦偺抣傪帩偮僆僽僕僃僋僩
	 * @param to 僐僺乕愭僆僽僕僃僋僩
	 * @param name 抣傪庢摼丒愝掕偡傞柤慜
	 * @return 曄姺屻偺抣
	 * @exception Exception 壗偐傜偺僄儔乕丅徻嵶儊僢僙乕僕偵偼 name 偑丄尨場偵偼尨場偲側偭偨椺奜偑愝掕偝傟偰偄傑偡丅
	 */
	public static final String dateTimeToString(Object from, Object to, String name) throws Exception {
		Date src = (Date) getObject(from, name);
		String value = toString(DATETIME_PATTERN[0], src);
		setObject(to, name, value);
		return value;
	}

	/**
	 * BigDecimal 偺抣傪丄String 偵曄姺偟偰僐僺乕偟傑偡丅<br>
	 *
	 * @param from 僐僺乕尦偺抣傪帩偮僆僽僕僃僋僩
	 * @param to 僐僺乕愭僆僽僕僃僋僩
	 * @param name 抣傪庢摼丒愝掕偡傞柤慜
	 * @return 曄姺屻偺抣
	 * @exception Exception 壗偐傜偺僄儔乕丅徻嵶儊僢僙乕僕偵偼 name 偑丄尨場偵偼尨場偲側偭偨椺奜偑愝掕偝傟偰偄傑偡丅
	 */
	public static final String bigDecimalToString(Object from, Object to, String name) throws Exception {
		return bigDecimalToString(from, to, name, DECIMAL_PATTERN[0]);
	}

	/**
	 * BigDecimal 偺抣傪丄String 偵曄姺偟偰僐僺乕偟傑偡丅<br>
	 *
	 * @param from 僐僺乕尦偺抣傪帩偮僆僽僕僃僋僩
	 * @param to 僐僺乕愭僆僽僕僃僋僩
	 * @param name 抣傪庢摼丒愝掕偡傞柤慜
	 * @param pattern 暥帤楍壔偡傞僷僞乕儞
	 * @return 曄姺屻偺抣
	 * @exception Exception 壗偐傜偺僄儔乕丅徻嵶儊僢僙乕僕偵偼 name 偑丄尨場偵偼尨場偲側偭偨椺奜偑愝掕偝傟偰偄傑偡丅
	 */
	public static final String bigDecimalToString(Object from, Object to, String name, String pattern) throws Exception {
		BigDecimal src = (BigDecimal) getObject(from, name);
		String value = toString(pattern, src);
		setObject(to, name, value);
		return value;
	}

	/**
	 * 抣傪丄偦偺傑傑僐僺乕偟傑偡丅<br>
	 *
	 * @param from 僐僺乕尦偺抣傪帩偮僆僽僕僃僋僩
	 * @param fromName 抣傪庢摼偡傞柤慜
	 * @param to 僐僺乕愭僆僽僕僃僋僩
	 * @param toName 抣傪愝掕偡傞柤慜
	 * @return 抣
	 * @exception Exception 壗偐傜偺僄儔乕丅徻嵶儊僢僙乕僕偵偼 name 偑丄尨場偵偼尨場偲側偭偨椺奜偑愝掕偝傟偰偄傑偡丅
	 */
	public static final Object objectToObject(Object from, String fromName, Object to, String toName) throws Exception {
		Object value = getObject(from, fromName);
		setObject(to, toName, value);
		return value;
	}

	/**
	 * 抣傪丄偦偺傑傑僐僺乕偟傑偡丅<br>
	 * 僐僺乕尦偺抣偑 null 偺応崌偼丄defaultValue 傪僐僺乕愭偵愝掕偟傑偡丅
	 *
	 * @param from 僐僺乕尦偺抣傪帩偮僆僽僕僃僋僩
	 * @param fromName 抣傪庢摼偡傞柤慜
	 * @param to 僐僺乕愭僆僽僕僃僋僩
	 * @param toName 抣傪愝掕偡傞柤慜
	 * @param defaultValue 僨僼僅儖僩抣
	 * @return 抣
	 * @exception Exception 壗偐傜偺僄儔乕丅徻嵶儊僢僙乕僕偵偼 name 偑丄尨場偵偼尨場偲側偭偨椺奜偑愝掕偝傟偰偄傑偡丅
	 */
	public static final Object objectToObject(Object from, String fromName, Object to, String toName, Object defaultValue) throws Exception {
		Object value = getObject(from, fromName);
		if (value == null) {
			value = defaultValue;
		}
		setObject(to, toName, value);
		return value;
	}

	/**
	 * String 偺抣傪丄偦偺傑傑僐僺乕偟傑偡丅<br>
	 *
	 * @param from 僐僺乕尦偺抣傪帩偮僆僽僕僃僋僩
	 * @param fromName 抣傪庢摼偡傞柤慜
	 * @param to 僐僺乕愭僆僽僕僃僋僩
	 * @param toName 抣傪愝掕偡傞柤慜
	 * @return 抣
	 * @exception Exception 壗偐傜偺僄儔乕丅徻嵶儊僢僙乕僕偵偼 name 偑丄尨場偵偼尨場偲側偭偨椺奜偑愝掕偝傟偰偄傑偡丅
	 */
	public static final String stringToString(Object from, String fromName, Object to, String toName) throws Exception {
		String value = (String) getObject(from, fromName);
		setObject(to, toName, value);
		return value;
	}

	/**
	 * String 偺抣傪丄Date 偵曄姺偟偰僐僺乕偟傑偡丅<br>
	 *
	 * @param from 僐僺乕尦偺抣傪帩偮僆僽僕僃僋僩
	 * @param fromName 抣傪庢摼偡傞柤慜
	 * @param to 僐僺乕愭僆僽僕僃僋僩
	 * @param toName 抣傪愝掕偡傞柤慜
	 * @return 曄姺屻偺抣
	 * @exception Exception 壗偐傜偺僄儔乕丅徻嵶儊僢僙乕僕偵偼 name 偑丄尨場偵偼尨場偲側偭偨椺奜偑愝掕偝傟偰偄傑偡丅
	 */
	public static final Date stringToDate(Object from, String fromName, Object to, String toName) throws Exception {
		String src = (String) getObject(from, fromName);
		Date value = toDate(DATE_PATTERN, src);
		setObject(to, toName, value);
		return value;
	}

	/**
	 * String 偺抣傪丄java.sql.Date 偵曄姺偟偰僐僺乕偟傑偡丅<br>
	 *
	 * @param from 僐僺乕尦偺抣傪帩偮僆僽僕僃僋僩
	 * @param fromName 抣傪庢摼偡傞柤慜
	 * @param to 僐僺乕愭僆僽僕僃僋僩
	 * @param toName 抣傪愝掕偡傞柤慜
	 * @return 曄姺屻偺抣
	 * @exception Exception 壗偐傜偺僄儔乕丅徻嵶儊僢僙乕僕偵偼 name 偑丄尨場偵偼尨場偲側偭偨椺奜偑愝掕偝傟偰偄傑偡丅
	 */
	public static final java.sql.Date stringToSqlDate(Object from, String fromName, Object to, String toName) throws Exception {
		String src = (String) getObject(from, fromName);
		java.sql.Date value = toSqlDate(DATE_PATTERN, src);
		setObject(to, toName, value);
		return value;
	}

	/**
	 * String 偺抣傪丄java.sql.Time 偵曄姺偟偰僐僺乕偟傑偡丅<br>
	 *
	 * @param from 僐僺乕尦偺抣傪帩偮僆僽僕僃僋僩
	 * @param fromName 抣傪庢摼偡傞柤慜
	 * @param to 僐僺乕愭僆僽僕僃僋僩
	 * @param toName 抣傪愝掕偡傞柤慜
	 * @return 曄姺屻偺抣
	 * @exception Exception 壗偐傜偺僄儔乕丅徻嵶儊僢僙乕僕偵偼 name 偑丄尨場偵偼尨場偲側偭偨椺奜偑愝掕偝傟偰偄傑偡丅
	 */
	public static final java.sql.Time stringToSqlTime(Object from, String fromName, Object to, String toName) throws Exception {
		String src = (String) getObject(from, fromName);
		java.sql.Time value = toSqlTime(DATE_PATTERN, src);
		setObject(to, toName, value);
		return value;
	}

	/**
	 * String 偺抣傪丄java.sql.Timestamp 偵曄姺偟偰僐僺乕偟傑偡丅<br>
	 *
	 * @param from 僐僺乕尦偺抣傪帩偮僆僽僕僃僋僩
	 * @param fromName 抣傪庢摼偡傞柤慜
	 * @param to 僐僺乕愭僆僽僕僃僋僩
	 * @param toName 抣傪愝掕偡傞柤慜
	 * @return 曄姺屻偺抣
	 * @exception Exception 壗偐傜偺僄儔乕丅徻嵶儊僢僙乕僕偵偼 name 偑丄尨場偵偼尨場偲側偭偨椺奜偑愝掕偝傟偰偄傑偡丅
	 */
	public static final java.sql.Timestamp stringToSqlTimestamp(Object from, String fromName, Object to, String toName) throws Exception {
		String src = (String) getObject(from, fromName);
		java.sql.Timestamp value = toSqlTimestamp(DATE_PATTERN, src);
		setObject(to, toName, value);
		return value;
	}

	/**
	 * String 偺抣傪丄BigDecimal 偵曄姺偟偰僐僺乕偟傑偡丅<br>
	 *
	 * @param from 僐僺乕尦偺抣傪帩偮僆僽僕僃僋僩

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -