Android中System.currentTimeMillis()
函数:
System.currentTimeMillis();
功能:产生一个当前的毫秒,这个毫秒事实上就是自1970年1月1日0时起的毫秒数,Date()事实上就是相当于Date(System.currentTimeMillis());
由于Date类还有构造Date(long date),用来计算long秒与1970年1月1日之间的毫秒差。
得到了这个毫秒数。利用函数Calendar终于出的结果就是年月日分秒。
System.currentTimeMillis() ;
获得的是自1970-1-01 00:00:00.000 到当前时刻的时间距离,类型为long
String.valueOf(System.currentTimeMillis()) 这个语句可转为下面的型式:
long ct = System.currentTimeMillis();
String t = String.valueOf(ct);
事实上上面的String t就相当于 ct+"",仅仅是转为字符串格式。
public String refFormatNowDate() {
Date nowTime = new Date(System.currentTimeMillis());
SimpleDateFormat sdFormatter = new SimpleDateFormat("yyyy-MM-dd");
String retStrFormatNowDate = sdFormatter.format(nowTime);
return retStrFormatNowDate;
}
Android中System.currentTimeMillis()的更多相关文章
- java中System.currentTimeMillis()
System.curentTimeMillis();会产生一个当前的毫秒. 1.计算某个方法的耗时 long curTime = System.currentTimeMillis(); resourc ...
- android中 System.exit(0)的理解
public class HelloGoodbye{ try{ System.out.println(“Hello World”); System.exit(0); } finally { Syste ...
- 关于System.currentTimeMillis()
一.时间的单位转换 1秒=1000毫秒(ms) 1毫秒=1/1,000秒(s)1秒=1,000,000 微秒(μs) 1微秒=1/1,000,000秒(s)1秒=1,000,000,000 纳秒(ns ...
- java: new Date().getTime() 与 System.currentTimeMillis() 与 System.nanoTime()
java使用new Date()和System.currentTimeMillis()获取当前时间戳 在开发过程中,通常很多人都习惯使用new Date()来获取当前时间,使用起来也比较方便,同时 ...
- [JAVA]比毫秒System.currentTimeMillis()更精确的时间戳(纳米级时间戳)
纳秒 ns(nanosecond):纳秒, 时间单位.一秒的10亿分之中的一个,即等于10的负9次方秒. 经常使用作 内存读写速度的单位,其前面数字越小则表示速度越快. 1纳秒=1000 皮秒 ...
- java的System.currentTimeMillis()和System.nanoTime
纳秒 ns(nanosecond):纳秒, 时间单位.一秒的10亿分之一,即等于10的负9次方秒.常用作 内存读写速度的单位,其前面数字越小则表示速度越快. 1纳秒=1000 皮秒 1纳秒 = ...
- System.currentTimeMillis和System.nanoTime()
ns(nanosecond):纳秒, 时间单位.一秒的10亿分之一,即等于10的负9次方秒.常用作 内存读写速度的单位. 1纳秒=0.000001 毫秒 1纳秒=0.00000 0001秒 jav ...
- android中:/system/bin/sh: : No such file or directory错误
将一个raspberry下编译好的可执行文件放在android的system/bin下,修改为777权限,运行,出现下面的错误: /system/bin/sh: XXX: No such file o ...
- Java 中时间处理 System.currentTimeMillis()
import org.testng.annotations.Test;import java.text.ParseException;import java.text.SimpleDateFormat ...
随机推荐
- luogu P2117 小Z的矩阵(结论题)
题意 题解 这题有点水. 我们发现对答案有贡献的实际上只有左上到右下的对角线上的数. 因为不在这条对角线上的乘积都要计算两遍,然后%2就都没了... 然后就做完了. #include<iostr ...
- linux 下的小知识
Linux中有7种启动级别 运行级别0:系统停机状态,系统默认运行级别不能设为0,否则不能正常启动运行级别1:单用户工作状态,root权限,用于系统维护,禁止远程登陆运行级别2:多用户状态(没有NFS ...
- vux安装时报vux-loader配置问题
一.初始化:webpack 项目塔建: 使用vue-cli塔建基于webpack的vue环境.然后根据vux官网安装使用文档安装vux组件库及配置build/webpack.base.conf.js. ...
- 紫书 例题8-19 UVa 12265 (扫描法+单调栈)
首先可以用扫描法处理出一个height数组, 来保存从当前行开始, 每一个格子可以向上延伸的最大长度. 这种"延伸"的问题用扫描法, 因为往往这个时候可以利用前一次的结果来更新当前 ...
- HDU 4725 The Shortest Path in Nya Graph
he Shortest Path in Nya Graph Time Limit: 1000ms Memory Limit: 32768KB This problem will be judged o ...
- UVA 11248 Frequency Hopping
Frequency Hopping Time Limit: 10000ms Memory Limit: 131072KB This problem will be judged on UVA. Ori ...
- VT-x is disabled in the BIOS. (VERR_VMX_MSR_VMXON_DISABLED)
参考以下文章: http://94it.net/a/jingxuanboke/2014/0717/368367.html
- Testing for SSL renegotiation
https://blog.ivanristic.com/2009/12/testing-for-ssl-renegotiation.html
- python 工具包安装
(1)wxPython是python的常用gui yum install wxPython (2)numpy, scipy是常用的数学处理工具包 yum install scipy
- AVEVA PDMS to DIALux
AVEVA PDMS to DIALux eryar@163.com Abstract. DIAL develops DIALux - the world's leading software f ...