av一区二区在线观看_亚洲男人的天堂网站_日韩亚洲视频_在线成人免费_欧美日韩精品免费观看视频_久草视

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

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

瀏覽:3日期: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
相關文章:
主站蜘蛛池模板: 色婷婷久久久久swag精品 | 欧美理论片在线观看 | 欧美理伦片在线播放 | 在线视频 亚洲 | 亚洲成人免费av | 最新国产精品视频 | 一区二区三区视频在线观看 | 97中文视频 | 91中文字幕在线 | 成人一级毛片 | 精品一区二区三区入口 | 一区天堂| 99re视频在线免费观看 | www.夜夜骑 | 成人免费看黄网站在线观看 | 久久综合一区二区 | 国产精品久久久久久久久久久久久久 | 日韩有码一区 | 伊人超碰在线 | 日韩电影在线一区 | 九九热这里只有精品6 | 好姑娘高清在线观看电影 | 69堂永久69tangcom | 国产中文字幕在线观看 | 欧美一区二区三区在线播放 | 国产精品一区久久久久 | 日韩视频在线播放 | 韩国久久精品 | 国产一区不卡 | 久国久产久精永久网页 | 草草影院ccyy | 免费黄色大片 | 日韩视频三区 | 国产线视频精品免费观看视频 | 蜜桃臀av一区二区三区 | 激情欧美一区二区三区中文字幕 | 黄网站涩免费蜜桃网站 | 精品久久久久一区二区国产 | 视频一区二区三区中文字幕 | 亚洲女人天堂成人av在线 | 亚洲欧美一区二区在线观看 |