Time Parser  from millisecond

Hi All,
How to parse a millisecond to a data format, such as hh:mm:ss.
I have a following code:
long start = System.currentTimeMillis();
//-- do some long task
long end = System.currentTimeMillis();
String elapsed = String.valueOf(end-start);
//then... how to convert to hh:mm:ssNow I want to parse the elapsedTime to the format of hh:mm:ss. I tried to use DateFormatter, but could not find a proper method for it.
Anyone has some experience on it? Could you drop me some line of code?
Many thanks.

Your problem is probably related to the fact that Dates are stored in a unversal time format, based on (as I recall) 0:00 GMT of 1st jan 1970.
Since you are in the states the Date/Time formatter routines, by default, will compensate for your local timezone (and also daylight saving time).
You could put Locale.UK in your DateDormat but you'd still have problems with daylight saving time.
Basically your problem is that the DateFormat is set up only to display actual dates and times, not intervals.
I think your best bet is to set up a Date with your local midnight (use Calendar and clear it), and add your time interval to that before formating.
Something like this should work:
static Data midNight;
static {
  Calendar cal = Calendar.getInstance();
  cal.clear();
  midNight = cal.getTime();
   String format = timeFormat.format(new Date(elapsed + midNight.getTime()));

Similar Messages

  • Decode time stamp from c-code

    Hi everybody,
    I have a TCP/IP where I send datagrams (in c-code) to LabVIEW (which is the server).
    The datagram sends with every data a time stamp in the following way: dd.mm.yyyy hh:mm:ss.zzz, where zzz stands for milliseconds. I would like to see my data in a waveform chart at the LabVIEW frontpanel, but I'm not sure how to get a continuous time stamp from the c-code. I tried it with "scan from string" (as my data enters LabVIEW as a string), and then I made a sum of the minutes (times 60) and the seconds, which works for one minute, but after one minute my time goes of course to zero again which isn't nice for the waveform chart...
    Does anybody has a nice idea how to solve this? Any examples?
    Thanks in advance!
    Steffi

    This code should help you,
    I only have a problem to read the final '.' my localization set the ',' as decimal sign and I can't get LabVIEW to change the decimal sign in this parser.
    Ton
    Message Edited by TonP on 02-01-2008 10:00 AM
    Message Edited by TonP on 02-01-2008 10:01 AM
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!
    Attachments:
    ScanTime.png ‏2 KB

  • Conversion from milliseconds to Date in 1.5

    A java.util.Date object can be constructed by passing the number of milliseconds since 1 January 1970 as a constructor argument. This Date can then be formatted to a human-readable format with SimpleDateFormat.
    I have tested this conversion from milliseconds to a date both in Java SDK 1.4.1 and Java 1.5.0 to see if there are differences in the way dates are calculated from milliseconds. It seems that there are differences when the system timezone is set to Europe/Berlin. The dates from 1.5.0 are one hour ahead of those from 1.4.1 in a certain week in May 1945 and a day in September 1945.
    This means that milliseconds that are generated from a date by using the Java 1.4.1 runtime and then stored are interpreted differently when they are retrieved when using java runtime 1.5.0, if they happen to be one of those days in 1945. This could cause discrepancies when an application is migrated to JDK 1.5.0.
    This is only a minor problem, but is there any way to know what caused these changes in SDK 1.5.0 and what these changes are? Is there historical data that the Sun implementation is based on to calculate dates from millisecond values?
    Any help is appreciated.
    Kind regards

    I found the following at "http://thedailywtf.com/forums/70146/ShowPost.aspx"
    In summer 1945, Berlin and the Soviet-occupied part of Germany observed a daylight savings time of two hours. Unfortunately, Sun's JRE 1.4 implementation of GregorianCalendar defines a maximum DST of one hour and, in non-lenient mode, rejects the 2 hours as invalid when recalculating all fields after the millisecond field is set.
    Here's the bug report: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4639407

  • Currency Translation not working with "Time Reference from Variable"

    We have created several Currency Translations using RSCUR with a fixed "Key Date".  All have been working fine until we got the request to allow a variable date for the exchange rate date.  I have built a variable on 0DATE which I am putting a default date value into using user exit.  This default date is the SAME date as the fixed "Key Date" which we have been using.  Unfortunately when we use the "Time Reference from Variable" option and use this new variable, no currency conversion is taking place, instead it only shows the original currency values.  I am 100% sure that my variable is getting a value and it is the same date we are using for the fixed "Key Date" value so both methods should be using the exact same exchange rates.  The documentation that I can find states:
    ●      Time reference: The time reference for the currency translation can be either fixed or variable.
    If the time reference is fixed, the time at which the exchange rate is determined is independent of the data. You have the following options:
    ○       You can establish that the time reference be determined upon translation.
    ○       You can select the current date.
    ○       You can specify a fixed date as the key date.
    ○       You can specify any variable that exists for InfoObject 0DATE.
    ○       You can establish that the query key date be used. This is determined in the query settings.
    In my case I am only switching from option "You can specify a fixed date as the key date"=(Key Date) to "You can specify any variable that exists for InfoObject 0DATE"=(Time Reference from Variable).
    What am I missing?  Any help is appreciated.

    I neglected to mention that we are calling this currency translation through a WAD button using the SET_CURRENCY_TRANSLATION command.  I did do a test by applying the currency conversion within query key figure.  This seems to work.  So it appears the issue is with how the WAD is processing the variable, not the query.  When I display the variable in a drop down item within the WAD it does have the default value that I have assigned in user exit.

  • To transfer time events from external time recording system to sap r/3

    hi all,
          I have a task to make an interface program between external time recording and sap r/3, and then to transfer the time events from that external system to sap system with the help of an rfc, i have got some information like the data first has to be transferred to the table CC1TEV and then from this table the data will be uploaded to 2011 infotype with the help of a standard program, but i am unable to find a solution for making the interface program and the RFC or BAPI which will transfer the records from external system.
        if anybody has any information on this plz help me out to solve this problem.

    Which recorgding terminals using to capture time events? They should have give some guidelines about this?
    Regards
    niranjan

  • I am having problems exporting my time lapses from quick time pro i need to save my files as photo jpegs but the standard video compression window will not open fully,

    i am having problems exporting my time lapses from quick time pro i need to save my files as photo jpegs but the standard video compression window will not open fully, it just keeps my mac (old 1.6Ghz 2.5 GB sdram G5 still good for most stuff i need) spinning for ever but i can see compression type H.264 selected and the other setting but i can not select any other options as it still thinking but never opens! why is this happening how do i get round it?
    my work flow is: 300 images shot on a 5d mark II medium jpegs opened in Light Room cropped to 16:9 then exported and opened in quick time i can save a .mov H264 giving me files sizes of 14 mb for a 16 second time lapse, mp4 9 mb. the only way i can get large files is saving as a self contained movie then i get 300mb files.
    i need to save my files 1920 x 1080 photo jpeg codec as i want HD quality.
    i am sure there is a simple way round this?
    thanks guys!

    It is very difficult to offer troubleshooting suggestions when the "os version" you are using is unknown as each os has their own troubleshooting solutions. 
    How large is your hard drive and how much hard drive space do you have left? 

  • How do I stop Time Machine from backing up Aperture thumbnails?

    Hi,
    My 2TB backup drive recently became full, and I became curious as to what was filling it up. I wrote a perl script to analyze the Time Machine backups, and I noticed that over 50% of my backup was filled with AP.Thumbnails and AP.Minis from the Aperture project directory. In particular, the AP.Thumbnails files in the backup consumed 737 GB of disk space!
    The problem with the thumbnails files is that they are a single file that contains all of the thumbnails for all of the 40,000 photos I have in Aperture and it is now 20gb in size. Every time I add a new file to Aperture, the thumbnail file changes, and I get a new 20gb of data added to my backup. I add photos often which means that most of my backups have 20gb of Aperture files (which are easy to rebuild and don't need to be backed up).
    I decided to try and stop Time Machine from backing up these files, and there seems to be no way of doing so (without telling Time Machine to skip backing up my entire Aperture project which I don't want to do). In Finder, you can do a "show package contents", but the Time Machine GUI doesn't allow this.
    I tried to tell Time Machine to exclude the files via the GUI, but Time Machine sees the Aperture Library as a single package and won't let me exclude individual files from within the package.
    I googled around, and found the attribute that Time Machine puts on files to exclude them from the backup. I used xattr to set the attributes:
    xattr -w com.apple.metadata:comapple_backupexcludeItem com.apple.backupd <filename>
    I also used this command on the iPhoto thumbnail files.
    I used spotlight to find all of the files with this attribute using this command:
    sudo mdfind "comapple_backupexcludeItem = 'com.apple.backupd'"
    This command returned the iPhoto files, but did not return the Aperture files.
    However, if I run "xattr" on the Aperture files, the attribute does exist!
    During my next time machine backup, the iPhoto files were skipped as I wanted them to be, but the Aperture thumbnails were backed up again
    I thought that maybe time machine was looking at the aperture package as an atomic unit, but iPhoto is stored as a package as well, and the attributes worked there on files inside the package.
    Does anyone have any idea why time machine is still backing up these files? Is there any way I can get around this?
    It seems to me to be an incredible oversight on Apple's part since both tools are Apple. The thumbnails files are very expensive to backup, and they are not necessary for backup since the are easy to rebuild from the original photos which are also backed up.
    Thanks,
    Ron

    Shadow99999 wrote:
    Hi,
    My 2TB backup drive recently became full, and I became curious as to what was filling it up. I wrote a perl script to analyze the Time Machine backups,
    No need to write your own script for that. there are a couple of already made nice GUI tools for this - TimeTracker http://www.charlessoft.com/ and BackupLoupe http://soma-zone.com/BackupLoupe/
    and I noticed that over 50% of my backup was filled with AP.Thumbnails and AP.Minis from the Aperture project directory. In particular, the AP.Thumbnails files in the backup consumed 737 GB of disk space!
    The problem with the thumbnails files is that they are a single file that contains all of the thumbnails for all of the 40,000 photos I have in Aperture and it is now 20gb in size. Every time I add a new file to Aperture, the thumbnail file changes, and I get a new 20gb of data added to my backup. I add photos often which means that most of my backups have 20gb of Aperture files (which are easy to rebuild and don't need to be backed up).
    I decided to try and stop Time Machine from backing up these files, and there seems to be no way of doing so (without telling Time Machine to skip backing up my entire Aperture project which I don't want to do). In Finder, you can do a "show package contents", but the Time Machine GUI doesn't allow this.
    I tried to tell Time Machine to exclude the files via the GUI, but Time Machine sees the Aperture Library as a single package and won't let me exclude individual files from within the package.
    I don't have aperture but I think most people exclude the whole thing from TM backups and back it up separately. but if you want to exclude a subfolder in a package that's easy too. just select the package in finder, control-click on it and select "show package contents". in the resulting finder window drill to the folder you want to exclude and drag it to the TM exclusion list in TM system preferences->options.
    I googled around, and found the attribute that Time Machine puts on files to exclude them from the backup. I used xattr to set the attributes:
    xattr -w com.apple.metadata:comapple_backupexcludeItem com.apple.backupd <filename>
    I was not aware of this method for excluding stuff from TM backups. could you provide a link to where you found this?
    I also used this command on the iPhoto thumbnail files.
    I used spotlight to find all of the files with this attribute using this command:
    sudo mdfind "comapple_backupexcludeItem = 'com.apple.backupd'"
    This command returned the iPhoto files, but did not return the Aperture files.
    that's because Spotlight never looks inside packages unless you start a search inside a package directly. iphoto seems to be the only exception. I don't know how it's done.

  • How do i use a Time Machine from another computer from Time Capsule with multibackups

    Can Iuse a Time Machine from another computer from Time Capsule with multibackups

    Not sure what you are asking here. 
    Time Machine is software on a Mac that is used to backup that Mac to a Time Capsule hard drive.
    Are you asking if another  Mac can backup to the same Time Capsule that other Macs are already using?
    Or, if not....please clarify on exactly what you want to do.

  • HT204380 How can I make a face time call from one country to another( supporsing both parties using iphone 4s). What will be the caller charges. If there is no charges as we use wifi, will there be a charge till connecting the call?

    How can I make a Face Time call from one country to another( supporsing both parties using iphone 4s). What will be the caller charges. If there is no charges as we use wifi, will there be a charge till connecting the call?

    FaceTime is free to use. You will not be charged for using FaceTime.

  • Access your TIme Capsule from a different network?

    Okay, I've been looking everywhere for a guide or how-to to do this, but my searches have been more or less fruitless, coming across outdated, incomplete or incompetent so-called "guides", so I thought I'd finally post a question myself, and see if anyone has actually been successful in doing this.
    What I want to do is be able to do is access all the files stored on my Time Capsule from anywhere (using accounts and/or passwords), provided I have an internet connection. I use my Time Capsule as an external hard drive, and it's great at home, but I have a lot of music, movies, photos etc that I don't have space for on my MacBook, so being able to connect to my Time Capsule from other locations would be awesome. I have seen many guides and how-to's, but no matter how closely I follow the steps, it never seems to work. If anyone has had any success using one of the guides, feel free to post the link below.
    I am running the latest firmware on the Time Capsule (7.5.2) - the serial number is 6F01208ZAQG if that helps, the latest version of Airport Utility (5.5.2), my Time Capsule is connected to the internet via a Thomson TG585 v7 router (via Ethernet cable), I am on a MacBook running OS X 10.6.5, which is connected wirelessly to the Time Capsule, and if it makes any difference I am in New Zealand.
    Any information would help, but if you're going to say "it doesn't work" or something not-so-helpful like that, could you please give a reason? I'm tired of you pessimists shooting everyone down.
    Thanks in advance,
    Ryan

    Welcome to the discussion area!
    It's been some time since I have used the "feature" to access files on the Time Capsule over the internet, so I can't remember all the details from 12-18 months ago. Some specifics I do remember:
    1) You must have a "static" IP address for your internet service from your ISP
    2) You must use a simple one port modem that will allow the Time Capsule to be the "main" router on the network
    3) You must use Mobile Me from Apple to set this up
    However, I notice that Apple no longer talks about this feature on the newer Time Capsule literature online, so that might be a hint that it is no longer being supported.
    When did have it working, even small file transfers took forever. The connection, if I was using wireless, was often lost before transfers could complete.
    I haven't tried the "how to" in the article below because I no longer travel for my job, but it might be worth a look for a different approach if Mobile Me is no longer providing this service.
    http://gigaom.com/apple/access-your-time-capsule-over-the-internet/
    Message was edited by: Bob Timmons

  • I can access my time capsule from my mac mini at work but my macbook can only access it from my home network. how do i fix this?

    I have a Mac Mini and a MacBook, both were configured at home to access the time capsule. I have since moved the mini to work to use there and it has no issues looking up files on the time capsule which remains at home. The macbook whoever can only access the time capsule from within the home network. I can't seem to find what I may have done differently. Can anybody help?
    Not sure if your allowed to post two questions, but it's may be related. I find that accessing the files on the time capsule from the mac mini or the macbook is very slow. Accessing the same files from an older HP laptop is as fast as accessing its own hard drive. How can I speed up the accessing of these files from my apple products. One would think they would work fast and the 'windows' computers would take minutes to map the drive each time... 
    Thanks for any help.

    I have since moved the mini to work to use there and it has no issues looking up files on the time capsule which remains at home.
    This cannot happen by magic though.. you must have configured the mini to access the TC remotely.. which method are you using, BTMM and iCloud??
    The macbook whoever can only access the time capsule from within the home network. I can't seem to find what I may have done differently. Can anybody help?
    How is the Macbook configured to access the TC remotely?? If you are trying to use BTMM and iCloud, then it might be a case that with the mini running the connection cannot be done by more than one computer at a time.. this is generally the case although I do not know if that is specifically true of BTMM method. Try turning off the mini and leave it off.. (off not standby)... then reboot the TC when you are at home.. and then try and connect the laptop to the TC the next morning from work. See if it is then able to capture the connection.. if so start up the mini and I suspect it now will not be able to connect.. that will prove that the TC cannot cope with two remote connections.
    There also could be another factor in here. If you are accessing the laptop via the same router as the mini is on.. then actually you cannot have two users mount the same files on a TC.. from the same IP address.. as far as the TC is concerned both devices have identical IP, that is the public IP of the work location router.
    If you happen to not be using BTMM then the situation is even easier.. you cannot make two different devices connect to the same network resource using the same port. That is the failing of the NAT system.. one device uses the port then it cannot be used by a second device. You will need to do some fancy footwork and use a different port.
    Anyhow tell us exactly how you are doing remote access.. otherwise I am just guessing.
    Not sure if your allowed to post two questions, but it's may be related. I find that accessing the files on the time capsule from the mac mini or the macbook is very slow.
    Are you talking about files you are hosting on the TC?? Not Time Machine backups??
    Can you tell me exactly how you are accessing the TC.. please do a test..
    Copy a file to the TC and from the TC using the Laptop.. Use a single very large file, eg 1GB movie file.
    Give me a read and write speed.. you can use activity monitor to give me an aprox average speed as well as peak.
    Do the same test from the same computer with wireless turned off running ethernet.
    Then do the tests from the mini.. same ones.. copy large file to and from the TC by ethernet and by wireless.. when using ethernet make sure wireless is off.
    I strongly recommend you set IPv6 to link local only for your wireless and ethernet setup in the Mac.
    eg
    Now do the test from the HP laptop and give me the results from that.
    Is the issue wireless only.. ??
    Then you might need to spend a bit of time fixing the wireless in the Macs.. you can run wireless diagnostics in Mavericks.
    About Wireless Diagnostics

  • How do I move data on time machine from one external hard drive to another

    How do I move data on time machine from one external hard drive to another?

    Although the documentation says you can copy Time Machine backups in the Finder, it's very slow and sometimes doesn't work at all.
    Launch Disk Utility, open the built-in help, and search for the term "Duplicate." Follow the instructions. Turn Time Machine OFF in its preference pane while copying the volume.

  • Can I share the files on the time capsule for all of the macs on my network and can I access time capsule from my laptop while out of town?

    I have a iMac desktop and a macbook pro.  If I purchase a time capsule, can I use it as the central location for my files for both computers?  Can I access the files on the time capsule from my macbook pro when I am out of town?

    Yes, with some provisos.. it is designed as primarily a backup location for Time Machine.
    Look at Pondini who has a great deal of info in his KB of all things Time Machine .. as well as Time Capsule.
    Q3 here. http://pondini.org/TM/Time_Capsule.html
    Remote access is via BTMM and iCloud.. just look it up.
    But the TC must be the main router in the network for it to work.

  • HT204380 i have a mac book pro and a i-pad 2. both of the devices have the same apple id and same mailing adress. if i want to make a face-time call from my mac book to i-pad 2. how can i do that?

    i have a mac book pro and a i-pad 2. both of the devices have the same apple id and same mailing adress. if i want to make a face-time call from my mac book to i-pad 2. how can i do that?

    You have to add another email address on one of the two devices that you can use as the "You can be reached for FaceTime at" contact address and then remove/uncheck the Apple ID email address as the contact address on that device. The way you are currently setup is like to trying to call yourself on your on phone - from your own phone.
    Using the iPad as the example go to Settings>FaceTime>You can be reached for FaceTime at>Add another email address. Then add a working email address in the next window. Apple will verify the email. Go to the inbox of that email account, read and respond to Apple's email in order to complete the verification process.
    Go back to Settings>FaceTime>Uncheck the Apple ID email address and make sure that the new email address is checked/selected (you will see it being verified again) and that new email address will be your contact address for the iPad.

  • TS2706 I cannot connect to my airport (time capsule) from a Windows PC

    Any information on how to connect to an aiport extreme (really the time capsule) from a Windows platform. Have no problem from our Mac's but cannot connect from a windows based platform.  I haven't been able to find any recent posts to help with this problem.

    First off, Archon23, what you want to achieve is possible.  I have access to both my Time Capsule (TC) and the USB drive connected to it, from a Win. 7 and Win. XP machine.
    Here is what I see from the Windows side of things:
         From My Computer - TC USB Drive (Y)
         From Windows HomeNet - Time Capsule:
    Now getting there is the trick.
    One caveat before proceeding:  I am not well versed in Windows Networks, Windows Sharing and Firewall settings so some of the following may not be elegant, may not be absolutely required, and may not be the best way of getting there.  But it is what I did to see both the TC drive and it's attached USB  drive on the Windows side of my network..
    1.) First, I added Airport Utility to the Inbound rules of Win 7 Firewall
    While poking around my Network Sharing and Firewall settings trying to figure this out, I got a Pop-up recommending I do that.  AND I did that. Oh, and while you are at it, make sure you have a Home network established. 
    2.) Next, on a hunch, I installed a USB Wi-Fi Adapter (under $20) to my Win PC, enabled that Wi-Fi connection and disabled my Ethernet connection.  I was getting no where on this matter with my Ethernet connection to a DSL Gateway.  But with a Wi-Fi connection to my AirPort Express Base Station, I made progress.
    3.) Finally, while poking around my Network Sharing Center some more, one by one I started the various network device Setup Wizards in there, and Trouble Shooters, to find the elusive TC/USB devices in question...AND voila, it worked.   And it's stable, been this way for going on two weeks now.
    Good luck.

Maybe you are looking for

  • How can I execute a dos command?

    I tryed so: import java.io.BufferedReader; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintStream; public class Builder {      public static void main(String[]args)                //m

  • PrintWriter strange behaviour

    PrintWriter outputStream = new PrintWriter(new FileWriter(filenameOut)); BufferedReader inputStream = new BufferedReader(new FileReader(filenameIn));I create a PrinterWriter like so, then I read a line of text from a text file using a BufferedReader

  • Psuedo code for changing a variable when my score is a multiple of 5?

    I have a game where I need to increase the difficulty when the score is a multiple of 5, does anyone think they could provide me with some psuedo code that would help me out with this? I have tried quite a few things and it hasn't worked out perfeclt

  • IPhone Ringtones Will not Work

    I bought three songs from iTunes and created three ring tones from them. Once I had created them, I attempted to sync them all into my iPhone but none worked, It informed me that my computer was unauthorized and I needed to authorize it by clicking o

  • Text not showing up on website

    my web is: bobayerstax.com it would appear that some/all(?) text/text graphics (flash symbols) are not showing up to some/all(?) viewers. would someone please tell me what i'm doing wrong. i've tried embedding the characters...but when i do that i ca