mirror of
https://gitee.com/egzosn/pay-java-parent.git
synced 2026-05-10 07:30:48 +08:00
代码优化
This commit is contained in:
@@ -15,11 +15,18 @@ import java.util.TimeZone;
|
||||
*/
|
||||
public final class DateUtils {
|
||||
public static final DateFormat YYYY_MM_DD_HH_MM_SS = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
public static final DateFormat YYYY_MM_DD = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
public static final DateFormat YYYY_MM_DD = new SimpleDateFormat("yyyy-MM-dd");
|
||||
public static final DateFormat YYYYMMDD = new SimpleDateFormat("yyyyMMdd");
|
||||
public static final DateFormat YYYYMMDDHHMMSS = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
public static final DateFormat MMDD = new SimpleDateFormat("MMdd");
|
||||
|
||||
static {
|
||||
YYYY_MM_DD_HH_MM_SS.setTimeZone(TimeZone.getTimeZone("GMT+8"));
|
||||
YYYY_MM_DD.setTimeZone(TimeZone.getTimeZone("GMT+8"));
|
||||
TimeZone timeZone = TimeZone.getTimeZone("GMT+8");
|
||||
YYYY_MM_DD_HH_MM_SS.setTimeZone(timeZone);
|
||||
YYYY_MM_DD.setTimeZone(timeZone);
|
||||
YYYYMMDD.setTimeZone(timeZone);
|
||||
YYYYMMDDHHMMSS.setTimeZone(timeZone);
|
||||
MMDD.setTimeZone(timeZone);
|
||||
}
|
||||
|
||||
public static final String format(Date date){
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.egzosn.pay.common.util;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
|
||||
public class Util{
|
||||
@@ -610,4 +611,23 @@ public class Util{
|
||||
return bt;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 元转分
|
||||
* @param amount 元的金额
|
||||
* @return 分的金额
|
||||
*/
|
||||
public static final int conversionCentAmount(BigDecimal amount){
|
||||
return amount.multiply(new BigDecimal(100)).setScale(0, BigDecimal.ROUND_HALF_UP).intValue();
|
||||
}
|
||||
/**
|
||||
* 元,两位小数
|
||||
* @param amount 元的金额
|
||||
* @return 元的金额 两位小数
|
||||
*/
|
||||
public static final BigDecimal conversionAmount(BigDecimal amount){
|
||||
return amount.setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user