System.currentTimeMillis();
产生一个自1970年1月1日0时起到当前的毫秒。
执行时间:
long startTime = System.currentTimeMillis();
......
long endTime = System.currentTimeMillis();
//打印执行时间
Systme.out.print(endTime-startTime);
当前时间
Date(System.currentTimeMillis());
2038年问题,java下不存在这个问题,不过可以模拟一下
Date date = new Date();
date.setTime((long)Integer.MAX_VALUE*1000);
System.out.println((long)Integer.MAX_VALUE*1000);
System.out.println(System.currentTimeMillis());
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:sss");
System.out.println(format.format(date.getTime()));
输出:
2147483647000
1455760659980
2038-01-19 11:14:007
分享到:
相关推荐
long haomiao = System.currentTimeMillis(); int b = (int)((haomiao/1000)%26+65); char daxiezimu = (char)b; System.out.println(haomiao); System.out.println(daxiezimu); } }
NULL 博文链接:https://buru.iteye.com/blog/1779991
主要介绍了System.currentTimeMillis()计算方式与时间的单位转换详解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
下面小编就为大家带来一篇Java获取当前系统事件System.currentTimeMillis()方法。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧
System.currentTimeMillis() SystemClock.uptimeMillis() SystemClock.elapsedRealtime() SystemClock.currentThreadTimeMillis 0、时间的单位: 秒:second 毫秒:Millisecond 微妙:Microsecond 纳秒:nanosecond ...
long timenow = System.currentTimeMillis(); for (String str : strs) { count++; } return System.currentTimeMillis() - timenow; } 2.比较慢 private long getTime2() { long time = 0; int...
long lasttick = System.currentTimeMillis(); GB2312Helper gb2312Helper = GB2312Helper.singleton(); String info1 = "测试汉字拼音和五笔"; CharacterRecord recs1[] = gb2312Helper.getRecords(info1);...
long beginTime = System.currentTimeMillis(); InputStream is = null; String ret = null; try { is = new BufferedInputStream( new FileInputStream(f) ); long contentLength = f.length(); ...
val start = System.currentTimeMillis() //logic val end = System.currentTimeMillis() val time = end - start println("[MTC] cost time:$time") } 本地调试模式下运行可以执行以下命令: ./gradlew :...
//加密 long lStart = System.currentTimeMillis(); String enString = AES.Encrypt(cSrc, cKey); System.out.println("加密后的字串是:" + enString); long lUseTime = System....
FakeTime使用本机Java代理将System.currentTimeMillis()实现替换为您可以使用系统属性进行控制的代理。 受启发。 public class ExamRegistrationServiceTest implements FakeTimeMixin { @Autowired ...
long begin=System.currentTimeMillis(); SortTest.class.getMethod(s, Number[].class).invoke(this, (Object)testNum); long end=System.currentTimeMillis(); System.out.println(s+":"+(end-begin)+...
// long begain = System.currentTimeMillis();//开始系统时间 // try { // Thread.sleep(100); // } catch (Exception e) { // e.printStackTrace(); // } // long CheckTime = System....
System.out.println("开始导出Excel文件: "+System.currentTimeMillis()); XlsExport e = new XlsExport(); // header e.createRow(0); for (ExportFiled filed : ExportFiled.values()) { e.setCell...
long start = System.currentTimeMillis(); ActiveXComponent app = new ActiveXComponent("Excel.Application"); // 启动excel(Excel.Application) try { app.setProperty("Visible", false); Dispatch ...
if(System.currentTimeMillis()-timeStamp > 5000){//如果时间间隔超过5秒 timeStamp = System.currentTimeMillis(); //重新记录时间 currPhoto = (currPhoto 1)%bmpPhotos.length; //更换照片 } canvas...
long start = System.currentTimeMillis(); try { // 打开word app = new ActiveXComponent("Word.Application"); // 获得word中所有打开的文档 Dispatch documents = app.getProperty("Documents")....
item.setOdrId(System.currentTimeMillis()); Long result=saleOrderServiceImpl.save(item); System.out.println(result); session.put("item", item); return SUCCESS; } catch (Exception e) { e....
long st = System.currentTimeMillis(); String fn = "MultiplicationTable.txt";//相对路径 :Java Project根目录 FileOutputStream fos = null; try { fos = new FileOutputStream(fn); for (int i = 1...
System.currentTimeMillis() ".mp4"; } Log.d("localUrl: " , localUrl); File cacheFile = new File(localUrl); if (!cacheFile.exists()) { cacheFile.getParentFile().mkdirs(); try {