将毫秒格式为分秒字节格式化成m

    技术2022-05-12  17

    /** * @param l整型的时间串 微秒 * @return 将微秒格式化为分:秒得形式 返回 */ public static String formatLongToTimeStr(int l) { String str = ""; int hour = 0; int minute = 0; int second = 0; second = l / 1000; if (second > 60) { minute = second / 60; second = second % 60; } if (minute > 60) { hour = minute / 60; minute = minute % 60; } String formatDate = null; if(hour>0){ formatDate = Integer.toString(hour)+":"+Integer.toString(minute)+":"+Integer.toString(second); }else{ formatDate = Integer.toString(minute)+":"+Integer.toString(second); } return formatDate; }

     

    将字节转化成兆 

     

    /** * @param aa byte类型的大小 * @return 格式化为m */ public String byteToM(int aa) { float temp = aa/1024f/1024f; String sizeStr = (temp + "").substring(0, 4)+"M"; return sizeStr; }


    最新回复(0)