国产成人精品久久免费动漫-国产成人精品天堂-国产成人精品区在线观看-国产成人精品日本-a级毛片无码免费真人-a级毛片毛片免费观看久潮喷

您的位置:首頁技術文章
文章詳情頁

Android 實現秒轉換成時分秒的方法

瀏覽:2日期:2022-09-24 08:39:23

在對時間進行轉換中,通常會把秒轉換成時分秒的小功能,怎么才能做到呢,其實也簡單 這就涉及到時分秒之間的相互轉換

具體代碼如下:

import android.content.Context;public class ToolsUtil { private static ToolsUtil toolsUtil; private Context mContext; private ToolsUtil(Context context) { mContext = context.getApplicationContext(); } public static ToolsUtil getInstance(Context context) { if (toolsUtil == null) { toolsUtil = new ToolsUtil(context); } return toolsUtil; } public String timeConversion(int time) { int hour = 0; int minutes = 0; int sencond = 0; int temp = time % 3600; if (time > 3600) { hour = time / 3600; if (temp != 0) { if (temp > 60) { minutes = temp / 60; if (temp % 60 != 0) { sencond = temp % 60; } } else { sencond = temp; } } } else { minutes = time / 60; if (time % 60 != 0) { sencond = time % 60; } } return (hour<10?('0'+hour):hour) + ':' + (minutes<10?('0'+minutes):minutes) + ':' + (sencond<10?('0'+sencond):sencond); }}

這樣就把時間轉換成 00:00:00 的時間格式了

ps:下面看下android通過秒換算成時分秒

把秒換算成時分秒

public static String cal(int second) { int h = 0; int d = 0; int s = 0; int temp = second % 3600; if (second > 3600) { h = second / 3600; if (temp != 0) {if (temp > 60) { d = temp / 60; if (temp % 60 != 0) { s = temp % 60; }} else { s = temp;} } } else { d = second / 60; if (second % 60 != 0) {s = second % 60; } } return h + '時' + d + '分' + s + '秒'; }

通過秒分別得出多少小時多少分多少秒

public class TimeUtils { public static String getHours(long second) {//計算秒有多少小時 long h = 00; if (second > 3600) { h = second / 3600; } return h+''; } public static String getMins(long second) {//計算秒有多少分 long d = 00; long temp = second % 3600; if (second > 3600) { if (temp != 0) {if (temp > 60) { d = temp / 60;} } } else { d = second / 60; } return d + ''; } public static String getSeconds(long second) {//計算秒有多少秒 long s = 0; long temp = second % 3600; if (second > 3600) { if (temp != 0) {if (temp > 60) { if (temp % 60 != 0) { s = temp % 60; }} else { s = temp;} } } else { if (second % 60 != 0) {s = second % 60; } } return s + ''; }}

總結

到此這篇關于Android 實現秒轉換成時分秒的方法的文章就介紹到這了,更多相關Android 秒轉換成時分秒內容請搜索好吧啦網以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持好吧啦網!

標簽: Android
相關文章:
主站蜘蛛池模板: 国产精品特黄一级国产大片 | 久久精品视频免费看 | 538prom精品视频在放免费 | 成人午夜大片免费看爽爽爽 | 亚洲一级香蕉视频 | 成人怡红院视频在线观看 | 国产一区国产二区国产三区 | 欧美在线一级精品 | 午夜爽爽性刺激一区二区视频 | 欧美日韩国产亚洲一区二区三区 | 欧美一区二区三区在线播放 | 美女黄频网站 | 欧美一级第一免费高清 | yy6080久久亚洲精品 | 一级做a爰片久久毛片美女 一级做a爰片久久毛片免费看 | 色噜噜狠狠大色综合 | 成年午夜性爽快免费视频不卡 | 美女一级毛片毛片在线播放 | 国产精品高清视亚洲一区二区 | 日韩一级欧美一级毛片在线 | 欧美日韩视频二区三区 | 九九精品国产兔费观看久久 | 国产精品人伦久久 | 欧美人与鲁交大毛片免费 | 亚洲综合日本 | 久久精品一区二区三区日韩 | 日本天堂视频在线观看 | 色偷偷88欧美精品久久久 | 免费一级大毛片a一观看不卡 | 一级毛片国产 | 99在线观看精品视频 | 一区不卡在线观看 | 热re91久久精品国产91热 | 国产午夜精品理论片久久影视 | 日韩精品一区二三区中文 | 一级毛片在线免费看 | 欧美在线二区 | 男女配种猛烈免费视频 | 国产欧美视频综合二区 | 免费一级肉体全黄毛片高清 | 亚洲最新在线视频 |