Class Calendar - why does it happen??

Hi.
I'm trying to compare two milliseconds values of Calendar objects. I expected to get the same milliseconds representation for the two objects. Somehow, it didn't happen:
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
SimpleDateFormat sdf1 = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
Calendar cal1 = Calendar.getInstance();
cal1.set(cal1.get(Calendar.YEAR), cal1.get(Calendar.MONTH), cal1.get(Calendar.DATE), 0, 0, 0);
Calendar cal2 = Calendar.getInstance();
cal2.setTime((Date)sdf.parse("09/11/2004"));
System.out.println("cal1: "+sdf1.format(cal1.getTime()));
System.out.println("cal2: "+sdf1.format(cal2.getTime()));
System.out.println("cal1 ms: "+cal1.getTimeInMillis());
System.out.println("cal2 ms: "+cal2.getTimeInMillis());
Output is:
cal1: 09/11/2004 00:00:00
cal2: 09/11/2004 00:00:00
cal1 ms: 1099951200453
cal2 ms: 1099951200000
I guess that it happened due to different millioseconds values for each object. Isn't the millisecond field of a Calendar object set to 0 by default?
Can someone please explain me what I'm missing here?
Thanks in advanced.

Isn't the millisecond field of a Calendar object set to 0 by default?No. Much like the year, month, day, hour, minute and second fields, the millisecond field of a Calendar
object is set to the millisecond value when the Calendar is created via getInstance().
: jay

Similar Messages

  • HT201317 Someother contacts and photostreams were uploaded to my iphone and mine were lost why does this happen to my apple id?

    Someother contacts and photostreams were uploaded to my iphone and mine were lost why does this happen to my apple id?

    The "system" performed as designed. All devices syncing to one iCloud account are kept in common sync. The idea is that all such devices belong to one user. Different users should have different iCloud accounts.  Once your contacts were edited, all devices were updated as well and subsequent backups (from yours and her device) reflected the changed contacts (and any other data that may have been edited like calendars). Your first task is to change your daughter over to a new account before she makes other changes.
    The only way I see for getting back contacts is to restore them from a time machine backup, assuming you also have a Mac included in the account which syncs the contacts. However, I'm not sure whether time machine includes contacts from iCloud along with those that are local, "on my Mac".
    Otherwise the deleted contacts are gone.

  • I cannot send an email from my iPad 2? No problem receiving, why does this happen? Have tried the suggestions for setting up email and after doing the sync mail through iTunes receiving worked great but still cannot send? Any help would be great

    I cannot send an email from my iPad 2? No problem receiving, why does this happen? Have tried the suggestions for setting up email and after doing the sync mail through iTunes receiving worked great but still cannot send? Any help would be great!

    The fact that you can receive means you have a valid e mail address, and have established the connection to the incoming server, so all of that works.  Since the send does not work, that means your outgoing server is rejecting whatever settings you used formthe outgoing set up.  Try them again. 
    Google your particular isp, and ipad and many times you will find the exact settings needed for your isp.  Or tell us here, and soneone else may be on the same isp.  Some mail services need you to change a port, or have a unique name for the outgoing server.  
    Kep trying.

  • I have Elements 11. Sometimes, if I edit a photo in Elements Editor, the date gets changed to the current date. Why does that happen? It doesn't happen all the time, so I can't isolate the cause. Any ideas?

    I have Elements 11. Sometimes, if I edit a photo in Elements Editor, the date gets changed to the current date. Why does that happen? It doesn't happen all the time, so I can't isolate the cause. Any ideas?

    I have Elements 11. Sometimes, if I edit a photo in Elements Editor, the date gets changed to the current date. Why does that happen? It doesn't happen all the time, so I can't isolate the cause. Any ideas?

  • TS4062 when i sync my iphone a large portion of my music does not download but rather stays in the cloud. then i must download it from the cloud. why does this happen and how can i stop it from happening

    every time that i sync my iphone with a cord to my imac some large portion of my music is placed in the cloud so that i must down load it from the cloud. this includes music that i have purchased on itunes and other music. it seems random.
    why does this happen? is it a setting? i want to stop it. and music that w

    It was gift back in September. You can follow the instructions in the link below to remove them:
    Remove iTunes gift album "Songs of Innocence" from your iTunes music library and purchases - Apple Support

  • Reinstalled Itunes and how have 4 to 8 copies of all music (7,500). This has happened before, called apple, sorry you will need to delete each. question why does it happen and can it corrected without one song at a time

    reinstalled itunes and have 4 to 8 copies of each song. This is the third time has happened over last 3 years. Called Apple, they state must delete extra songs manually, is there a quicker way and why does this happen. I have Iphone, can I delete all music and copy from phone?

    Man I hear your pain, same happened to me. I never worked out a way of deleting all the duplicates and I'm guessing it occured as you imported your library more than once.
    However it is possible to delete everything and copy from an ipod using different utilities out there on the net, try googling ipodutil as an expample, although I don't know if this works from an iphone but it worked for me copying everything back from an ipod into itunes.

  • I have not had any issue with Itunes on my PC until recently. Every now and then my Itunes library appears on my screen?  I have not clicked the itunes icon beforehand nor plugged in my Ipod Touch?  Why does ths happen please. I have windows XPPOdany ic

    I have not had any issue with Itunes on my PC until very recently. Every now and then my Itunes library appears on my screen?  I have not clicked the itunes icon beforehand nor plugged in my Ipod Touch?  Why does this happen please as it is driving me crazy!.

    What's the precise text of the message, please? (There's a couple of different ones I can think of that you might be getting.)

  • My iphone is suddenly populated by random songs I've downloaded in the past. Why does this happen, and what are apple doing about fixing this?

    Why does this happen?
    What do other people do? (I can't go to sleep knowing there's a rogue album or song in my music. It's 2am now)
    What do we tell apple so that they actually fix it. None of us want to pay £25 to have our own music.

    I am on the monthly payment plan because nobody at BT has told me there is any alternative!
    Each year there I have a long, in-depth conversation with the person who sets up the contract for the next year but the gist of the thing is 'I'm  not going to be paying more than [x amount] per month, am I? Because I can't afford any more'' and each year the person says that no, in fact I should be paying less... and then without notice and even with the bill saying 'We will continue to take....' a totally different - and higher - sum disappears from my bank account.
    Then I go through the painful process of writing to complain about this, get some sort of sum refunded and then the payments go through at the level they should, with me paying any additional (usually small) amounts for usage over the allowance. Until contract end when we start all over again...
    Even if the amount they seem to randomly decide on is based on some sort of forecast, this should not be happening as I am doing what they instruct me to do on the bill to keep my payments the same.
    So something is going wrong, on many levels.
    At no point have I been offered the sort of 'monthly billing' described here; maybe there is some reason I am not allowed it. Unfortunately 'whole bill' direct debit payment is beyond me. I really need to know what I will be paying each month and I need BT to correctly take that amount, as agreed, each month, from the get-go.
    It shouldn't be that hard really! Does anyone from BT read these forums? Can somebody take this on and finally get this straight, please?

  • I have downloaded Firefox 4.0 several times and after a short amount of time (days) it reverts back to 3.6.16. Why does it happen and how do I prevent it from happening again?

    The Firefox 4.0 on my laptop reverts back to 3.6.16. This has happened several times. Why does this happen and/or how do I prevent it from happening again?

    Thanks for the link. I just downgraded to the absolute shtfest that's 4.0. I WAS just fuming about how gawdawful this "new" version is, but after wasting so much time trying to sort thru all the issues caused by this 4.0 downgrade (past updates have always been seamless and troublefree - not so for this shtfest!) I'm flat-out RAGING!!! Fortunately the laptop still has 3.6.xx running - it's the LAST version of Firefox it will EVER see. I switched to Firefox so many years ago to get away from the insanity and frustration of Explorer - if this 4.0 crapshoot is the "future" of Firefox, then the incompetent nimrods responsible for it know where they can ram it. I'm starting the search for a new browser now - so long Firefox, it's been fantastic while it lasted, but you've gone and screwed the pooch, you've ruined a superb browser!
    I'll attempt a reload of 3.6.xx on the desk machine, and if successful I'll run it till it drops, or I find a suitable replacement browser, but 4.0 won't be coming back - GOOD RIDDANCE!!!

  • HT2500 I sometimes get e-mails where the sender sends me several PDF's attachments. These attachments appear already opened on the e-mail unlike most PDF's which I open by clicking on the PDF icon. Why does this happen?

    I sometimes get e-mails with pdf attachments. However instead of opening a PDF icon the body of the e-mail message has the PDF's already opened. Why does this happen? Is there anything I can change on my mac book pro to make these PDF's come thru with their individual icons which can then be opened.

    This is a long-standing design flaw in Apple Mail.
    Prior to Mavericks, this command in Terminal would stop the annoying behavior:
    defaults write com.apple.mail DisableInlineAttachmentViewing -bool yes
    This Terminal command stopped working in Mail 7.1 under Mavericks. I have reported this to Apple as both a feature request and a bug. You should too.
    http://www.apple.com/feeback

  • I have songs i ripped from cds on my computer.  after a while, some of them have started to skip? why does this happen? do i have to rip them all over again?

    i have songs i ripped from cds on my computer.  after a while, some of them have started to skip.  why does this happen?  do i have to rip them all over again?

    See Recover your iTunes library from your iPod or iOS device.
    tt2

  • When i scan my ipod from the application named find my ipod touch 4 it simply shows location unavailable while that of my cousin's ipod touch exactly shows the same location..... Why does that happen???

    When i scan my ipod from the application named find my ipod touch 4 it simply shows location unavailable while that of my cousin's ipod touch exactly shows the same location..... Why does that happen???

    When you go to the Google Maps app on the iPod does it correctly find your location? The iPod's locations service uses the location of the a nearby wifi router to locate te iPod.  However, not all routers are in Apple's database and as of yet nobody here knows of a way to add routers to the database.

  • When my most front window is a safari one and I use the shortcut key "Command N", it opens a new finder window and a new safari window at the same time. Why does it happen?

    When my most front window is a safari one and I use the shortcut key "Command N", it opens a new finder window and a new safari window at the same time. Why does it happen?

    I just found the solution!
    Niel
    Re: Why is my Finder window popping up when I open my Safari window? 
    Jan 20, 2008 7:58 PM (in response to alak)
    Open the General tab of the Safari preferences and correct the home page; the default page is this one. If it has become set to a folder on an FTP server or a local drive, that request will be sent to the Finder. (28252) 
    iMac Late 2007 Core 2 Duo, Mac OS X (10.5.1)

  • While trying to instal Mountain Lion OS on my macbook pro, I got the error message that my HD was damaged and it reverted to my Lion OS. Why does this happen? I bought the OS online through the app store

    While trying to instal Mountain Lion OS on my macbook pro, I got the error message that my HD was damaged and it reverted to my Lion OS. Why does this happen? I bought the OS online through the app store.

    The Mountain Lion installer looks at your internal drive to make certain that it's error-free before continuing installation. You should have an application named "Install OS X Mountain Lion.app" in your Applications folder now so you shouldn't have to download it again. Do this...
    Boot to your Lion recovery partition by holding down both the Command and the R keys while booting. Open Disk Utility from the Recovery partition and select your hard drive (usually named "Macintosh HD" unless you've renamed it) and click on Verify Disk. If you come up with any errors, click on Repair Disk. At the end of the cycle you will get a message that the disk was successfully repaired or a message that the hard drive could not be repaired.
    If you're able to repair the disk, just reboot as normal and open the "Install OS X Mountain Lion.app" and the installation will proceed. If Disk Utility was unable to repair the disk, you need to get to your local Apple Store as soon as possible so that they can see if the disk is salvageable or beyond repair.
    Good luck,
    Clinton

  • The monitor of my MacBook Pro suddenly became all black, I tried to reset but it did not work, what should I do? Why does this happen?

    The monitor of my MacBook Pro suddenly became all black, I tried to reset but it did not work, what should I do? Why does this happen?

    I advise to reply to the one you want to reply to.
    You have had good information here. I will not repeat that here.
    I would like to add:
    you have incompatible software: start in SafeMode, read Woodmeister and see if it is free of issues.
    Akamai is crap software needed or not, Huawei the same.
    It is very possible that the keygenerator you used for generating a key for some softwares has infected your mac.
    The non-regular software with the false key(s) are not compatible probably or generate malware. Luckily you can not update them automatically because the keygenerator blocked the software for contacting the developer... I propose to consider getting rid of those softwares by really good uninstalling.
    You have a beautiful mac, don't degenerate it with crapped software. There are alternatives for expensive software, for example Adobe Photoshop has a free alternative (with a less beautiful interface) in GIMP. And so on.
    Lex

Maybe you are looking for

  • IPhoto won't stay open (I know it's been asked)

    The only pieces of advice I've found is to reinstall, delete the plist, and delete the cache. I have done all of these at least 5 times, and it still opens for about 10 seconds, then shuts down and gives me the error message I will put at the end of

  • I'm running 5.0.1 but I keep getting message saying I'm not running current version and I'm not protected how can I fix this?

    When I run firefox I get the following message: URGENT! Your version of Firefox is no longer protected against online attacks. Get the upgrade - it's fast and free! I am running 5.0.1 and have tried upgrading several times and still get the same mess

  • Dreamweaver/Flash literature

    I am switching from GoLive to Dreamweaver and Flash. I am using the Classroom in a Book tutorials to familiarize myself with those applications, but can already tell they're only scratching the surface. Therefore I'd like to know what literature is r

  • Errors in ovs_query.log

    looking at the log file under /var/log/ovs-agent/ovs_query.log I see some errors. "2009-05-28 15:41:44" INFO=>ha_check_cluster_heartbeat: shared_fs='/dev/sda2' failed. "2009-05-28 15:41:44" INFO=> get_live_vms:start... "2009-05-28 15:41:44" INFO=> ge

  • Will you include form filling in the next release?

    I really need to be able to fill out and save fillable PDF forms with Adobe Reader Touch.  Microsoft Reader has limited support for filling pdf forms, but it frequently will not save the filled-in form.  Will Adobe Reader Touch have this feature soon