午夜剧场伦理_日本一道高清_国产又黄又硬_91黄色网战_女同久久另类69精品国产_妹妹的朋友在线

您的位置:首頁技術(shù)文章
文章詳情頁

Android 實(shí)現(xiàn)秒轉(zhuǎn)換成時分秒的方法

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

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

具體代碼如下:

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); }}

這樣就把時間轉(zhuǎn)換成 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) {//計(jì)算秒有多少小時 long h = 00; if (second > 3600) { h = second / 3600; } return h+''; } public static String getMins(long second) {//計(jì)算秒有多少分 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) {//計(jì)算秒有多少秒 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 + ''; }}

總結(jié)

到此這篇關(guān)于Android 實(shí)現(xiàn)秒轉(zhuǎn)換成時分秒的方法的文章就介紹到這了,更多相關(guān)Android 秒轉(zhuǎn)換成時分秒內(nèi)容請搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!

標(biāo)簽: Android
相關(guān)文章:
主站蜘蛛池模板: 久久久久久国产精品视频 | 五月激情六月丁香 | 黄色v片 | 成年人激情网 | 色婷婷亚洲综合 | 日本欧美在线观看视频 | 亚洲一区在线免费 | 婷婷狠狠操| 91精选| 婷婷成人av| 日韩视频区 | 成人激情视频在线播放 | 男人疯狂高潮呻吟视频 | 欧美成人一级片 | 中文字幕在线视频免费观看 | 性高潮视频在线观看 | 一级黄色片a | 欧美午夜一区 | 日韩亚洲欧美在线观看 | 中文字幕高清在线 | 午夜亚洲一区 | 日韩精品导航 | 色黄大色黄女片免费中国 | 色蜜桃| 伊人网在线 | 午夜精品网站 | 日韩在线观看一区二区 | 麻豆国产视频 | 三区四区在线观看 | 五月天婷婷综合网 | 永久免费看mv网站入口亚洲 | 99热这里只有精品在线观看 | 日本黄色免费大片 | 日本视频中文字幕 | 国内免费av| 罗曼蒂克消亡史在线观看 | 91免费入口 | 日韩不卡在线 | 婷婷色网 | 欧美黄视频在线观看 | 色第一页 |