From b9f963aba187310ac39ba84e8ef46e38aaaed80c Mon Sep 17 00:00:00 2001
From: DELL <1525436766@qq.com>
Date: 星期二, 06 八月 2024 14:58:07 +0800
Subject: [PATCH] BTS调试工具中新增剩余容量续航时长展示

---
 Device_Simulator_DTS_Tester/src/com/Com.java |   52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 52 insertions(+), 0 deletions(-)

diff --git a/Device_Simulator_DTS_Tester/src/com/Com.java b/Device_Simulator_DTS_Tester/src/com/Com.java
index 84ae1ac..c784ae2 100644
--- a/Device_Simulator_DTS_Tester/src/com/Com.java
+++ b/Device_Simulator_DTS_Tester/src/com/Com.java
@@ -354,4 +354,56 @@
 	public static void setTFDocLimit(JTextField tf, int charlen, String str) {
 		tf.setDocument(new LimitedDocument(charlen, str));
 	}
+	
+	/**
+	 * 将时间转化成H:M:S
+	 * @param min
+	 * @return
+	 */
+	public static String minConvertHourMinSecond(Integer min) {
+		String result = "";
+		if (min != null) {
+			Integer m = min;
+			String format;
+			Object[] array;
+			Integer days = m / (60 * 24);
+			Integer hours = m / (60) - days * 24;
+			Integer minutes;
+			Integer second;
+			if (days > 0) {
+				hours += days * 24;
+				minutes = m - hours * 60;
+				second = ( m - minutes - hours * 60) / 60;
+			}else{
+				minutes = m - hours * 60 - days * 24 * 60;
+				second = (m - minutes - hours * 60) / 60;
+			}
+			String hoursstr = null;
+			String minutesstr  = null;
+			String secondstr = null;
+			if(hours < 10){
+				hoursstr = "0"+hours;
+			}else {
+				hoursstr = hours + "";
+			}
+			if(minutes < 10){
+				minutesstr="0"+minutes;
+			}else {
+				minutesstr = minutes + "";
+			}
+			if(second < 10){
+				secondstr="0"+second;
+			}else {
+				secondstr = second + "";
+			}
+			format = "%1$s:%2$s:%3$s";
+			array = new Object[]{hoursstr, minutesstr,secondstr};
+			result = String.format(format, array);
+		}
+		return result;
+	}
+	
+	public static void main(String[] args) {
+		System.out.println(minConvertHourMinSecond(61));
+	}
 }

--
Gitblit v1.9.1