com.mrcd.mmat.util.UnitUtil Maven / Gradle / Ivy
The newest version!
package com.mrcd.mmat.util;
/**
*
Description: 单位转换
*
*
*
Author: chenlin
*
Date: 10/22/21
*/
public class UnitUtil {
public static Long kbToBytes(Long num){
return num << 10;
}
public static Long mbToBytes(Long num){
return num << 20;
}
public static Long byteToKB(Long num){
return num >> 10;
}
public static Long byteToMB(Long num){
return num >> 20;
}
public static Long KBToMB(Long num){
return num >> 10;
}
public static Long KBToGb(Long num){
return num >> 20;
}
public static Long mbToKB(Long num){
return num << 10;
}
public static String kB2MStdOut(long num) {
if(num > 1024){
return KBToMB(num)+" MB\n";
}else{
return num + " KB\n";
}
}
public static String b2MStdOut(long num) {
if(num > kbToBytes(1024L)){
return byteToMB(num) + " MB\n";
}else{
return byteToKB(num) + " KB\n";
}
}
}