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 ...
随机推荐
- 优动漫PAINT简简单单绘画绣球花
本文分享使用优动漫PAINT简简单单绘画绣球花教程: 相关资讯还可以关注http://www.dongmansoft.com 最后告诉你绣球花的花语,还是很和谐美好的呢! 绣球花没有茉莉花的芳香四溢, ...
- asp.net core 与EFcore 入门
什么是EFcore? Entity Framework (EF) Core 是轻量化.可扩展和跨平台版的常用 Entity Framework 数据访问技术,EF Core 可用作对象关系映射程序 ( ...
- JS自定义全局Error
<script> ///自定义错误 onerror=handleErr; function handleErr(msg,url,l) { var txt=""; txt ...
- CSS常用样式--font
CSS font 属性 参考:W3school- CSS font 所有浏览器都支持 font 属性,可在一个声明中设置所有字体属性,各属性需按顺序,语法如下: selector{ font:styl ...
- linux 调试相关命令
1. tail -f filename 调试时,log输出到文件,但是又想看到即时输出信息 未完待续....
- vue+element-ui+slot-scope或原生实现可编辑表格(日历)
你们公司的产品是不是还在做一个可编辑表格功能? 1.前言 咱开发拿到需求大多数是去网上找成型的组件,找不到再看原生的方法能否实现,大牛除外哈,大牛一般喜欢封装组件框架. 2.思路 可编辑表格在后台管理 ...
- nginx proxy_set_header设置,自定义header
在实际应用中,我们可能需要获取用户的ip地址,比如做异地登陆的判断,或者统计ip访问次数等,通常情况下我们使用request.getRemoteAddr()就可以获取到客户端ip,但是当我们使用了ng ...
- 洛谷 P3662 [USACO17FEB]Why Did the Cow Cross the Road II S
P3662 [USACO17FEB]Why Did the Cow Cross the Road II S 题目描述 The long road through Farmer John's farm ...
- zookeeper 安装笔记 3.6.7
1 下载 ZK wget http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.4.7/zookeeper-3.4.7.tar.gz 2 解 ...
- CentOS-6.4-minimal版中源代码安装MySQL-5.5.38
完整版见https://jadyer.github.io/2014/09/29/centos-install-mysql/ /** * CentOS-6.4-minimal版中源代码安装MySQL-5 ...