在java 中如果取得系统当前时间,精确到微秒,格式为,yyyy-MM-dd hh:mm:ss.nnnnnn

解决方案 »

  1.   

    Letter Date or Time Component Presentation Examples
    G Era designator Text AD
    y Year Year 1996; 96
    Y Week year Year 2009; 09
    M Month in year Month July; Jul; 07
    w Week in year Number 27
    W Week in month Number 2
    D Day in year Number 189
    d Day in month Number 10
    F Day of week in month Number 2
    E Day name in week Text Tuesday; Tue
    u Day number of week (1 = Monday, ..., 7 = Sunday) Number 1
    a Am/pm er Text PM
    H Hour in day (0-23) Number 0
    k Hour in day (1-24) Number 24
    K Hour in am/pm (0-11) Number 0
    h Hour in am/pm (1-12) Number 12
    m Minute in hour Number 30
    s Second in minute Number 55
    S Millisecond Number 978
    z Time zone General time zone Pacific Standard Time; PST; GMT-08:00
    Z Time zone RFC 822 time zone -0800
    X Time zone
    没有 n 表达的
      

  2.   

    System.nanoTime()不过在这个级别上,不保证完全精确
      

  3.   

    javax.realtime.HighResolutionTime.getNanoseconds()
      

  4.   

    Timestamp 就可以精确到微妙 
      

  5.   

    System.nanoTime();是个是纳秒。除上1000就是微秒了
      

  6.   

    nanoTime
    public static long nanoTime()
    Returns the current value of the most precise available system timer, in nanoseconds. This method can only be used to measure elapsed time and is not related to any other notion of system or wall-clock time. The value returned represents nanoseconds since some fixed but arbitrary time (perhaps in the future, so values may be negative). This method provides nanosecond precision, but not necessarily nanosecond accuracy. No guarantees are made about how frequently values change. Differences in successive calls that span greater than approximately 292 years (263 nanoseconds) will not accurately compute elapsed time due to numerical overflow.  For example, to measure how long some code takes to execute: 
       long startTime = System.nanoTime();
       // ... the code being measured ...
       long estimatedTime = System.nanoTime() - startTime;
     Returns:
    The current value of the system timer, in nanoseconds.
    Since:
    1.5