Results 1 to 2 of 2
  1. #1
    jitman is offline Member
    Join Date
    Mar 2010
    Posts
    2
    Rep Power
    0

    Default Current Time in millisecs

    Hello,

    I am trying to get current system time in millisecs and am using the below code.

    long currentTime = System.currentTimeMillis();

    However, it gives me some different value (it appears it calculates number of millisecs that have passed since 1 Jan '1970)

    I want to calculate the time in millisecs for only the single day e.g. Time 13:06should give me value as ((13*60*60) + (06*60))*1000 millisecs

    Is there any standard java function that can help.

    Thanks,

  2. #2
    Steve11235's Avatar
    Steve11235 is offline Senior Member
    Join Date
    Dec 2008
    Posts
    1,046
    Rep Power
    7

    Default

    First of all, System.currentTimeMillis() may only be accurate to 10-15 milliseconds, depending on the OS and the hardware.

    Use GregorianCalendar to get today's date and convert it to a long. Subtract that from currentTimeMillis.

Similar Threads

  1. Class Time - represents time of day
    By verbazon in forum New To Java
    Replies: 1
    Last Post: 04-13-2009, 01:06 AM
  2. Current month
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-07-2008, 08:40 AM
  3. Getting current userís name
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-07-2007, 12:04 PM
  4. how to get the current date and time
    By valery in forum New To Java
    Replies: 1
    Last Post: 08-03-2007, 06:05 PM
  5. How can i get current directory?
    By Ashley in forum New To Java
    Replies: 1
    Last Post: 05-26-2007, 01:21 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •