java获取当前系统毫秒,纳秒】的更多相关文章

//获取当前系统毫秒 System.out.println(System.currentTimeMillis()); //获取当前系统纳秒 System.out.println(System.nanoTime());…
转载: http://blog.csdn.net/zzjjiandan/article/details/8372617 一. 获取当前系统时间和日期并格式化输出: import java.util.Date;import java.text.SimpleDateFormat; public class NowString {public static void main(String[] args) { SimpleDateFormat df = new SimpleDateFormat("yy…
获取当前系统的时间,每隔一秒,打印一次. import java.util.Date; public class TestDate { public static void main(String[] args) { while (true) { System.out.println(new Date()); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } } } } 获取当前…
import java.util.Date; public class Timestamp { /** 获取精确到毫秒的时间戳 * @param date * @return **/ public static Long getTimestamp(Date date){ if (null == date) { return (long) 0; } String timestamp = String.valueOf(date.getTime()); return Long.valueOf(time…
原文:http://www.open-open.com/code/view/1426152165201 import java.io.BufferedReader; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.HashMap; import java.util.Li…
//SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式 SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); String datetime = sdf.format(new Date());//new Date()为获取当前系统时间4 System.out.println(datetime);…
System.currentTimeMillis()产生一个当前的毫秒,这个毫秒其实就是自1970年1月1日0时起的毫秒数,Date()其实就是相当于Date(System.currentTimeMillis());因为Date类还有构造Date(long date),用来计算long秒与1970年1月1日之间的毫秒差. 得到了这个毫秒数,我们自己也可以算起现在的年月日周时,但是这不是我们去计算的,因为有Calendar.Calendar最终出的结果就是年月日周时时区. System.curre…
//获取系统的字体 public static void getLocalFontFamily(){ GraphicsEnvironment ge=GraphicsEnvironment.getLocalGraphicsEnvironment(); String [] fontName=ge.getAvailableFontFamilyNames(); for(int i=0;i<fontName.length;i++){ System.out.println(fontName[i]); } }…
Java的Date获取时间函数都是deprecated 可以使用: https://stackoverflow.com/questions/5175728/how-to-get-the-current-date-time-in-java 所说方法 It depends on what form of date / time you want: If you want the date / time as a single numeric value, then System.currentTim…
System.currentTimeMillis()产生一个当前的毫秒,这个毫秒其实就是自1970年1月1日0时起的毫秒数,Date()其实就是相当于Date(System.currentTimeMillis());因为Date类还有构造Date(long date),用来计算long秒与1970年1月1日之间的毫秒差. 得到了这个毫秒数,我们自己也可以算起现在的年月日周时,但是这不是我们去计算的,因为有Calendar.Calendar最终出的结果就是年月日周时时区. System.curre…