45 lines
947 B
Plaintext
45 lines
947 B
Plaintext
|
package com.surfbird.util.convert;
|
|||
|
|
|||
|
import java.text.DecimalFormat;
|
|||
|
|
|||
|
/**
|
|||
|
* 4-20Ma<4D><61><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD>ʽ.
|
|||
|
* @author Administrator
|
|||
|
* 2018.11.05
|
|||
|
**/
|
|||
|
public class DataFormula {
|
|||
|
|
|||
|
/**
|
|||
|
* <20><><EFBFBD><EFBFBD><EFBFBD>¶ȱ<C2B6><C8B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(0-100)
|
|||
|
* @param value
|
|||
|
* @return
|
|||
|
**/
|
|||
|
public static String toT100(String value) {
|
|||
|
DecimalFormat format = new DecimalFormat("#####0.##");
|
|||
|
int result = Integer.parseInt(value, 16);
|
|||
|
return format.format(result/160.0);
|
|||
|
}
|
|||
|
|
|||
|
/**
|
|||
|
* <20><><EFBFBD><EFBFBD><EFBFBD>¶ȱ<C2B6><C8B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(0-150)
|
|||
|
* @param value
|
|||
|
* @return
|
|||
|
**/
|
|||
|
public static String toT150(String value) {
|
|||
|
DecimalFormat format = new DecimalFormat("#####0.##");
|
|||
|
int result = Integer.parseInt(value, 16);
|
|||
|
return format.format(result/106.67);
|
|||
|
}
|
|||
|
|
|||
|
/**
|
|||
|
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Сһ<D0A1>ٱ<EFBFBD>.
|
|||
|
* @param value
|
|||
|
* @return
|
|||
|
**/
|
|||
|
public static String toSmallerHundred(String value) {
|
|||
|
DecimalFormat format = new DecimalFormat("#####0.##");
|
|||
|
int result = Integer.parseInt(value, 16);
|
|||
|
return format.format(result/100.0);
|
|||
|
}
|
|||
|
}
|