Milliseconds to Seconds Minutes

is there a way to take a number (specifically the position in
milliseconds that a sound has been playing) and convert it into
minute:second format? any help?
jeff

Hi Jeff
Here a code snippet that I'm using for my flash mp3 player.
function timer(sound_obj) {
time = sound_obj.position/1000;
min = Math.floor(time/60);
min = (min<10) ? "0"+min : min;
sec = Math.floor(time%60);
sec = (sec<10) ? "0"+sec : sec;
timeDisplay_txt.text = min+":"+sec+"/"+totalDuration;
function duration() {
timed = _root.sound_mc.sound_obj.duration/1000;
mind = Math.floor(timed/60);
mind = (mind<10) ? "0"+mind : mind;
secd = Math.floor(timed%60);
secd = (secd<10) ? "0"+secd : secd;
totalDuration = mind+":"+secd;
keep in mind to create a textfield with the instancename of
"timeDisplay_txt" and to call the timer function at least every
second using the setInterval statement.
Tiago

Similar Messages

  • There is screen information of Airplay popping up on the screen every second minute. How do I get rid of this window? Everything is already connected

    There is screen information of Airplay popping up on the screen every second minute. It's stating: 1. Network Configuration: Connect to wifi network 2. Choose this Apple TV. However wifi is already connected and this apple tv has been chosen. How do I get rid of this window as everything is working already fine and everything is connected. Airplay and wifi are working already.

    Had this happen to me after a recent update, was super annoying.  To turn off, go to Settings > AirPlay > Conference Room Display > Off.

  • Converting "minutes.seconds.milliseconds" to "seconds.milliseconds"

    Hello
    I have string (string a = 1.15.67) which represents time (minutes. seconds. milliseconds).
    Which is the easiest way to get a Double which holds the above mentioned time, where minutes are converted to seconds (double b = 75.67)?
    Should i convert the above mentioned String to a Date object first or is this not neccesary?
    Edited by: user10496629 on 17.03.2011 14:03

    jduprez wrote:
    To be honest, my knowledge of FP arithmetic comes mostly from reading this forum, and I'm sure you contributed to such discussions in the past - so I'm surprised to read your arguments.
    Except myself I would use integral types (int, or long to be conservative) to hold the number of seconds/milliseconds. I don't see what double would bring except inaccurracy that will build up when you add/combine multiple durations.Yeah, but given that he wants the end result to include a fractional piece, he's going to have inaccuracies anyway?
    Not if he stores the number of milliseconds, and only formats it at display time.Oh, I see what you're saying now.
    Still, unless he's dealing with very large scales, he can store as a double, format for display, and any inaccuracies will wash out in the format. That is, even though 12345.67 cannot be stored in a double, most likely he will be able to ignore that, store 12345.67000000001, and format it so that it displays as 12345.67.
    Whether that or a separate integer piece representation is more appropriate depends on other requirements and use cases that the OP hasn't shared with us. :-)
    >
    And it's highly likely that the integer numbers of minutes, seconds, and millis that are represented individually will be exactly representable by double.
    In fact, if he keeps millis and seconds in their expected ranges, it's guaranteed that they are, and the only possible parsing inaccuracy is in minutes, and even then, the entire range of int can be exactly represented, so it'd be an awful lot of minutes before he started losing precision there.Either I misunderstand you, or what you say is not correct:
    System.out.println(0.1D+0.2D+0.3D);Results in:
    0.6000000000000001
    But when you format for display, you'll get 0.600.

  • Scripting WLC show commands (ie show client detail) every x seconds/minutes

    Is there a simple way to script using either a terminal client (putty, teraterm, etc.) or Prime Infrastructure whereby I could set up a set of commands to be run at a certain interval?
    I want to conduct some client testing roaming across a site whilst some how performing a show client detail every 15 seconds and a show run-config every 30 minutes?
    TIA,
    Nick

    Is there a simple way to script using either a terminal client (putty, teraterm, etc.) or Prime Infrastructure whereby I could set up a set of commands to be run at a certain interval?
    Yes you can. 
    The easiest method is to use console.  You can knock up a script to run the command at specific intervals and log the outputs.  If you do this, you must ensure the console timeout is expanded. 
    Another option is to create a PERL script (using KRON) to telnet/SSH into the appliance and run the command and retrieve the results. 

  • All apps just shut downs after few seconds/minutes.  I have reset Ipad but did not help. What next?

    - Have an Ipad 2 with IOS 5(01?) installed.

    Reset the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider - let go of the buttons.
    If that doesn't help - try downloading another app - any free app will work. See if that helps.

  • Dv6910us shuts off within seconds-minutes

    Hello. I have owned my Pavilion dv6910us for a year and a half. This evening, I sprayed some compressed air into the vents to dislodge some dust from the fans. I did this before about a year ago when my fans began to run loudly. Please note that the computer was turned off and unplugged when I did this 
    When I started the computer again, it booted up and I got to open my Firefox browser before the computer shut off without warning. Now I can't get the computer up to the vista startup screen. It usually gets to the screen where it tells me that my computer was not properly shut down before turning off.
    I noticed that the fan that usually starts when I boot up no longer turns on. I can hear the hard drive booting up, however. The computer remains cool and everything. I'm pretty sure I did something when I sprayed the compressed air into the vents. What can I do to remedy this?
    I will also mention. that I installed some vista updates right before I shut the computer down to spray it. I'm not sure if this is an issue. I was also having problems with the computer intermittently going from AC to battery power even though the computer remained plugged in.
    I'll appreciate any help. Thanks.

    UPDATE: The computer stays on now, but the fan isn't working at all. I used HWMonitor and the temperatues were around 80 degrees celsius. I'm sure that's not a good temperature.

  • When trying to send a text or email my phone hesitates several seconds before sending it.  Sometimes minutes

    I try to send a text message and my iphone 5 hesitates for several seconds or minutes before sending.  When trying to change screens it will stick for several seconds/minutes also.

        Gumbydpl, we appreciate your efforts in trying to resolve this issue on your own. Has the owner of that mobile number tried reaching out to their wireless provider to ensure that there's no restrictions for sending text messages to your mobile number?
    Lasina_VZW
    Follow us on Twitter @VZWSupport

  • I have serious problems with I OS 6 - I am loosing internet connection after a few seconds or minutes. What can I do? Can I come back IO S 5.1.1.?

    I am experiencing serious problems after downloading iOS 6. I am loosing my connection after a few seconds/minutes. What can I do? Can you come back to 5.1.1.? How can I do that?

    You can't downgrade the iOS.
    Look at iOS Troubleshooting Wi-Fi networks and connections  http://support.apple.com/kb/TS1398
    iPad: Issues connecting to Wi-Fi networks  http://support.apple.com/kb/ts3304
    iOS: Recommended settings for Wi-Fi routers and access points  http://support.apple.com/kb/HT4199
    Additional things to try.
    Try this first. Turn Off your iPad. Then turn Off (disconnect power cord for 30 seconds or longer) the wireless router & then back On. Now boot your iPad. Hopefully it will see the WiFi.
    Go to Settings>Wi-Fi and turn Off. Then while at Settings>Wi-Fi, turn back On and chose a Network.
    Change the channel on your wireless router (Auto or Channel 6 is best). Instructions at http://macintoshhowto.com/advanced/how-to-get-a-good-range-on-your-wireless-netw ork.html
    Another thing to try - Go into your router security settings and change from WEP to WPA with AES.
    How to Quickly Fix iPad 3 Wi-Fi Reception Problems
    http://osxdaily.com/2012/03/21/fix-new-ipad-3-wi-fi-reception-problems/
    If none of the above suggestions work, look at this link.
    iPad Wi-Fi Problems: Comprehensive List of Fixes
    http://appletoolbox.com/2010/04/ipad-wi-fi-problems-comprehensive-list-of-fixes/
    Fix iPad Wifi Connection and Signal Issues  http://www.youtube.com/watch?v=uwWtIG5jUxE
    Fix Slow WiFi Issue https://discussions.apple.com/thread/2398063?start=60&tstart=0
    Unable to Connect After iOS Update - saw this solution on another post.
    https://discussions.apple.com/thread/4010130
    Note - When troubleshooting wifi connection problems, don't hold your iPad by hand. There have been a few reports that holding the iPad by hand, seems to attenuate the wifi signal.
    ~~~~~~~~~~~~~~~
    If any of the above solutions work, please post back what solved your problem. It will help others with the same problem.
     Cheers, Tom

  • How can I make a while loop wait 10 seconds before iterations​?

    I am using labview to for an osmosis system that measures the amout of water lost from the reading on a scale.  
    I currently have the program displaying the data from 3 scales every second.
    I also need to calculate the flux through the membrane over time.
    I do this with a function that takes a change in the scale reading over time (with a shift register) followed by a series of mathematical conversions.
    The readings from the scale display OK every second, but I need to have at least 10 seconds between flux calculations.
    So my question is, how do I make a the shift register take one value from the scale, then wait 10 seconds before taking the second value?  That way I have the mass of water lost over a 10 msecond period.  
    Below is my current while loop for Flux using shift registers from data from 3 scales.  
    Any helkp would be great!
    Also, I'm new at LabVIEW...

    Bob_Schor wrote:
    Do you understand how Dataflow (a key idea behind LabVIEW) works?  If you put a Wait (ms) function (on the Timing Palette) with 10000 (10,000 milliseconds = 10 seconds) inside your While Loop, the principles of Data Flow will require all of the functions inside the While (specifically the Wait function) to finish their execution before the loop can run again.  As everything else in the loop takes approximately 0 seconds, this will make your loop run once every 10 seconds.
    Bob Schor
    I do not think that is a good idea. 
    The inner loop should be in sync with the outer loop, not run independent on it's own timer.
    If the inner loop is running independently you run the risk of using stale data.
    Actually  altenbach is right the inner loop does not need to be a for loop at all, but rather just a case like my suggestion (without the for loop) and the shift registers should be out on the main loop.
    My suggestion was a quick solution going by what little bit of the block diagram I could see, but if the entire code was posted I am sure we would see where more improvements could be made and possibly even a better solution.

  • Throttling a file adapter to consume a max number of files per minute

    Is there a way to design a file adapter to throttle its processing bandwidth.
    A simple use case scenario is describes as follows;
    A File Adapter can only consumes a max of 5 files per minute. The producer average throughput is 3 files per minute but during peak times it can send 100 files per min. The peak times occur during end of year or quarterly accounting periods. If the consumer consumes more than 5 files per min the integrity of the environment and data is compromised.
    The SLA for the adapter is to :
    - Each file will be processed within 2 seconds.
    - Maximum File Transactions Per minute is 5
    An example is as follows.
    The producer sends 20 files to its staging directory within a minute. The consumer only processes 5 of these files in the first minute, sleeps then wakes up to consume the next 5 files in the second minute. This process is repeated until all files are processed.
    The producer can send another batch of files when ever it likes. So in the second minute the producer can send another 70 files. The consumer will throttle the files so it only processes 5 of these files every minute.

    Hi,
    If you have a polling frequency set to 2 secs..then controlling it to read only five files a min is difficult.?You can have the polling frequecy changed to 12secs
    or u can schedule a BPEL for every min and use synchronous read operation and loop it 5 times to read 5 files.

  • Seconds to hr/min/sec conversion error

    I typed up this simple sample program and for some reason when I execute it, I get one second less than the actual value. For instance, I typed in 9999 and got 2 hours, 46 minutes, 38 seconds. It should be 39. What did I do wrong? Here's the code:
    import cs1.Keyboard;
    public class Tim
    public static void main (String[] args)
    final int CONVERSION = 60;
    final double HOUR_CONVERSION = 3600.0;
    int hour1, minute1, seconds1;
    double seconds, minute, hour;
    System.out.print ("How many seconds have you been sleeping? ");
    seconds = Keyboard.readInt();
    hour = seconds / HOUR_CONVERSION;
    minute = (hour - (int)hour) * CONVERSION;
    seconds = (int) ((minute - (int)minute) * CONVERSION);
    hour1 = (int) hour;
    minute1 = (int) minute;
    seconds1 = (int) seconds;
    System.out.print ("You slept for " + hour1 + " hours, "
    + minute1 + " minutes, and "
    + seconds1 + " seconds.");

    My suspicion is a rounding error. When you do the
    last conversion to seconds, I supect you are getting
    something like 38.99999999. and just in case it wasn't clear (no offense, EE), converting fp types to int types in Java always truncates, so (int)38.99999999999 ends up as 38.

  • TM2 Touchscreen takes a few seconds to work

    My tm2 works great with the pen.  No problems with the pen.  The problem is when I use a finger.  If I have  my finger away from the screen for several seconds, minutes, or whatever and touch the screen, it doesn't work.  I have to hold my finger on the screen for a couple of seconds before the touch will work.  If I keep my finger pressed to the screen, I will always have touch capabilities.....Man this is hard to explain.  Let me try a different approach - it seems that my tm2 takes a couple of seconds to register my finger before the touchscreen works.  I can be browsing the internet for example, and find an article I am reading.  While reading I have no reason to have my finger on the screen to control anything.  Once I am done and need to perform an action - like scroll down, hit the back button, whatever, I put my finger on the screen to perform the action and nothing happens -it doesn't register my finger being there for two seconds or so.  This causes me to only use the pen, since two seconds is a long time when doing something on a computer!
    The tm2 is a month or so old, I bought new from HPs website.  It has been this way since I bought it.  Is this the way its supposed to work?  Or perhaps a setting I am missing?  any help would be very apprecaited, I love this computer and I am hoping I don't have to return it to be fixed (I don't want to be away from it for long).  Thanks for listening!

    Hey,
    I think I have the exact problem as you with the HP Pavilion dv6.  My finger always needs to be touching the screen for around a full second before the touch function is activated.  
    I have been searching the whole internet with no luck on any help and the only closest post I have found is your.
    What is funny is that just minutes after finding your post I think I have solved the problem!
    For my laptop the problem came from the computer turning off my touchscreen device/driver to save power.  
    So, what I did is that I went into "Device Manager" from "My Computer".
    Then once inside "Device Manger", underneath the "Human Interface Devices" catagory I found "Wacom Gesture Touch", which I guessed is the device that is controlling my touchscreen.  
    Once inside "Wacom Gesture Touch", I clicked the "Power Managment" tab and found and UNCHECKED the "Allow the computer to turn off this device to save power" option.
    And that was it!  Now my touch screen response to my finger the moment it touches the screen.
    Go to device manger and see if you have any luck of finding the device/driver that is controlling/driving your touch screen and see if this helps.
    Hopefully this can solve your problem too!  It has been bothering me for the longest time.

  • PowerMac MDD freeze seconds after start

    Hello,
    I have problems with my PowerMac MDD since months, I tried lot of things, but now it's getting worse and worse.
    It used to freeze without warning (mostly with Safari), I tried to change to Fireforks with no luck.
    It then freezed more often, I take back the memory chip that the previous owner added, I disconnected the mouse from the keyboard, added a new generic usb mouse directly in the USB port, nothing.
    Now, after two kernel panics, my Mac freeze slowly within seconds, minutes eventually when I login with a new user account, even if I don't launch anything, and with ethernet unplugged (no internet).
    The last time, they where lines of tiny dots visible in the logging window, and in finders window.
    The processor has been changed if it is important, it's a Gigadesign G-celerator 2xPPC G4 1,42GHz.
    I suspect a hardware problem, but I can't imagine what is wrong...
    Thanks for any advise,
    Antilog
    PowerMac MDD   Mac OS X (10.4.8)  

    OK, I tried all the test on Dr Smokes Page, and this is the same.
    I tested even open firmware
    set-defaults
    reset-nvram
    reset-all
    It helped me maintaining my mac alive for enough time to copy the panic.log on an usb-key.
    So here's the log (sent with the help of a PC!)
    Sat Nov 18 15:53:42 2006
    panic(cpu 1 caller 0x000A50C8): simple lock (0x0038CFD4) deadlock detection, pc=0x0003D754
    Latest stack backtrace for cpu 1:
    Backtrace:
    0x00095718 0x00095C30 0x0002683C 0x000A50C8 0x0003D754 0x000B4654 0x000ADDD4 0x000AC348
    Proceeding back via exception chain:
    Exception state (sv=0x20FA5500)
    PC=0x00033DE8; MSR=0x00009030; DAR=0x01294000; DSISR=0x42000000; LR=0x00033DE8; R1=0x0CF93E30; XCP=0x00000024 (0x900 - Decrementer)
    Backtrace:
    0x00033D90 0x000A9914
    Exception state (sv=0x2094E000)
    PC=0x00000000; MSR=0x0000D030; DAR=0x00000000; DSISR=0x00000000; LR=0x00000000; R1=0x00000000; XCP=0x00000000 (Unknown)
    Kernel version:
    Darwin Kernel Version 8.7.0: Fri May 26 15:20:53 PDT 2006; root:xnu-792.6.76.obj~1/RELEASE_PPC
    Is there something interresting in this log?
    Thanks for your help

  • Wrt54g ver7 connection lost after a minute

    my pc's internet was running smoothly when it was connected directly to a modem/router (zyxel). but when i hook up a wrt54g v7 (latest firmware installed) it only connects maybe up to a minute then losses its connection. i ping the router for the first minute and it was replying but after the first or the seconde minute, it shows "request time out".
    another thing, i connect the modem/router (zyxel) and the wrt54g (i did not connect the pc to the wrt54g) , then tried to connect my Wii wirelessly and it was detected and connected to the net, and surfing good.
    now i dont know whats the problem, is it my pc or sumthing else?
    thanks
    Message Edited by cir09uevhe on 09-26-2007 10:09 PM
    Message Edited by cir09uevhe on 09-26-2007 10:10 PM

    thanks for the reply, i already updated the firmware and i think it was the latest...
    i have another question, i change the mode of my wrt54g to "Router" mode and it connected easily to my PC, but when i use my Wii to connect wirelessly it happend to search for the wrt54g but cant connect to the net...
    is it possible, to use this router as an access point?...i dont know if this setup is ok. or can the wireless capability of wrt54g be effective in its "Router" mode?...
    thanks sir

  • I made a new Date object

    See, here's the thing with dates in java, the way i see it. We used to have Date, but Date wasn't international so we got Calendar. But some things, like SimpleDateFormat, still expect java.util.Date. java.sql.Date is out there somewhere, too. None of them have direct support for date differences (i.e. dateA - dateB = 8 days, or whatever). Now you're probably reading this thinking "Java supports all of this" and you're right. Calendar has a getTime method that returns a Date, and i can just pass THAT to SimpleDateFormat. With a little math, getTimeInMillis can be used to find the difference in two Calendars. But i got to thinking, "There should only be one Date object i need to think about," and since i don't ever have enough to do at work i put one together. I don't know if any of you are going to care enough to use it, mostly i'm just looking for advice on features i should add to it, inefficiencies in the design, stuff that's hard to understand, or whatever.
    This is it:
    *This catastrophe brought to you by SrA Meyerin.
    *Proximo Satis pro administatio.
    package awesomedate;
    //The following are imported for the toFormattedString(), toUtilDate(), toSQLDate, and toCalendar() methods, respectively.
    import java.text.SimpleDateFormat;
    import java.util.Date;
    import java.util.GregorianCalendar;
    import java.sql.*;
    import java.util.TimeZone;
    *This class is designed to be the ultimate date object. It stores dates accurate to the millisecond, has the ability to do date
    *arithmetic (adding/subtracting days/months/whatever), date comparison, and date formatting. Also it can, at will, be used as any
    *of the other date objects in the standard java API.
    public class AwesomeDate
         *Milliseconds from the epoch. This field is where everything starts.
        private long millis;
         * The current year. This is the only aspect of the current date that is stored in addition to the milliseconds. Everything else
         * is calculated as needed.
        private int year;
        //The following six variables are fairly self explanatory. I'll explain them anyway.
         *Milliseconds in one non-leap year. This can be passed to the "adjustDate()" method
         * but mostly it is used to make my code more readable.
        public final static long MILLIS_IN_YEAR = 31536000000L;
         *Milliseconds in one leap year. This can be passed to the "adjustDate()" method
         * but mostly it is used to make my code more readable.
        public static final long MILLIS_IN_LEAP_YEAR = 31622400000L;
         *Milliseconds in one day. This can be passed to the "adjustDate()" method
         * but mostly it is used to make my code more readable.
        public static final long MILLIS_IN_DAY = 86400000;
         *Milliseconds in one hour. This can be passed to the "adjustDate()" method
         * but mostly it is used to make my code more readable.
        public static final long MILLIS_IN_HOUR = 3600000;
         *Milliseconds in one minute. This can be passed to the "adjustDate()" method
         * but mostly it is used to make my code more readable.
        public static final long MILLIS_IN_MINUTE = 60000;
         *Milliseconds in one second. This can be passed to the "adjustDate()" method
         * but mostly it is used to make my code more readable.
        public static final long MILLIS_IN_SECOND = 1000;
         *The number of days in each month.
        private int[] daysInMonth = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
         *The timezone offset. GMT is 0, and the default, however, CST (where i live), is -6.
        private int timeZoneOffset = -6;
         *As the name would indicate, this is the number of milliseconds beyond 00:00 of jan 1 of the current year.
        private long millisAfterYear;
         *Basic constructor. Defaults to the current date and time. Works on Greenwich Mean Time, so it may seem off. To avoid this, multiply
         *add your time zone offset * MILLIS_IN_HOUR to the time in milliseconds.
        public AwesomeDate()
            setTimeInMillis(System.currentTimeMillis());
         *Fairly simple constructor. Sets time to the the number of milliseconds passed past the epoch.
        public AwesomeDate(long millis)
            setTimeInMillis(millis);
         *This constructor sets the date to the year/month/day passed.
        public AwesomeDate(int year, int month, int day)
            setDate(year, month, day);
         *This constructor sets the date time to the year/month/day/minute/hour/second passed.
        public AwesomeDate(int year, int month, int day, int hour, int minute, int second)
            setDate(year, month, day, hour, minute, second);
         *When you have the number of milliseconds, the first thing you must calculate is year. Because the number of milliseconds in a
         *year may vary, this is also the most difficult to calculate. This is the method that does it, though.
        private void setYearAfter1970()
            //I don't want to alter the actual number of milliseconds, so i make this variable and perform calculations on it.
            long theseMillis = this.millis;
            //Start at 1970 (the epoch) and work from there.
            year = 1970;
            long nextYear = MILLIS_IN_YEAR;
            //In this loop i subtract the number of millis in whatever year. The condition is if i have enough millis to make it through
                //another year.
            while (theseMillis >= nextYear)
                if (isLeapYear(year))
                    theseMillis = theseMillis - MILLIS_IN_LEAP_YEAR;
                    nextYear = MILLIS_IN_YEAR;
                else
                    theseMillis = theseMillis - MILLIS_IN_YEAR;
                    if (isLeapYear(year + 1))
                        nextYear = MILLIS_IN_LEAP_YEAR;
                year++;
            millisAfterYear = theseMillis;
            this.year = year;
         *Calculating the year from before 1970 must be done differently. It's pretty much just inverted.
        private void setYearBefore1970()
            long theseMillis = this.millis;
            year = 1970;
            long nextYear = MILLIS_IN_YEAR;
            while (theseMillis <= 0)
                if (isLeapYear(year))
                    theseMillis = theseMillis + MILLIS_IN_LEAP_YEAR;
                    nextYear = MILLIS_IN_YEAR;
                else
                    theseMillis = theseMillis + MILLIS_IN_YEAR;
                    if (isLeapYear(year - 1))
                        nextYear = MILLIS_IN_LEAP_YEAR;
                year--;
            millisAfterYear = theseMillis * -1;
            this.year = year;
         *Just what it sounds like. Pass it the number of milliseconds past the epoch and it will calculate the date based on that.
        public void setTimeInMillis(long millis)
            this.millis = millis;
            if (millis >= 0)
                setYearAfter1970();
            else
                setYearBefore1970();
         *Returns the number of milliseconds from the epoch.
        public long getTimeInMillis()
            return this.millis;
         *Returns the current year.
        public int getYear()
            return this.year;
         *Sets the date to 00:00 of Jan 1 of the passed year.
        public void setYear(int year)
            this.year = year;
            long theseMillis = 0;
            if (year > 1970)
                //Kind of like setYearAfter1970 method, except it's adding instead of subtracting. So actually it's the opposite.
                for (int cntr = 1970; cntr < this.year; cntr++)
                    if (isLeapYear(cntr))
                        theseMillis = theseMillis + MILLIS_IN_LEAP_YEAR;
                    else
                        theseMillis = theseMillis + MILLIS_IN_YEAR;
            else
                for (int cntr = 1970; cntr > this.year; cntr--)
                    if (isLeapYear(cntr))
                        theseMillis = theseMillis - MILLIS_IN_LEAP_YEAR;
                    else
                        theseMillis = theseMillis - MILLIS_IN_YEAR;
            //On a leap year there are 29 days in February. If not, there's 28.
            if (isLeapYear(year))
                daysInMonth[1] = 29;
            else
                daysInMonth[1] = 28;
            //This variable helps me calculate denominations of time that are below year.
            millisAfterYear = 0;
            setTimeInMillis(theseMillis);
         *Sets the month to the one that you passed, 0 being January and 11 being December.
        public void setMonth(int month)
            if (month < 0 || month > 11)
                throw new ArrayIndexOutOfBoundsException(month);
            long theseMillis = getTimeInMillis();
            int days = 0;
            setYear(this.year);
            if (getTimeInMillis() > 0)
                theseMillis = theseMillis - getTimeInMillis();
            else
                theseMillis = theseMillis + getTimeInMillis();
            for (int cntr = 0; cntr < month; cntr++)
                days = days + daysInMonth[cntr];
            millisAfterYear = days * MILLIS_IN_DAY + 1;
            setTimeInMillis(getTimeInMillis() + millisAfterYear);
         *Returns the month stored in this object. With this object 0 represents January and 11 represents December.
        public int getMonth()
            long theseMillis = millisAfterYear;
            int cntr = 0;
            while (theseMillis > (MILLIS_IN_DAY * daysInMonth[cntr]))
                theseMillis = theseMillis - MILLIS_IN_DAY * daysInMonth[cntr];
                cntr++;
            return cntr;
         *Set the day of month to the one passed.
        public void setDayOfMonth(int day)
            if (day < 1 || day > daysInMonth[getMonth()])
                throw new ArrayIndexOutOfBoundsException(day);
            setMonth(getMonth());
            //Internally, this actually works starting at zero, however to anyone using this class it appears to start at 1. Therefore
                //i must subtract one here.
            long addMillis = MILLIS_IN_DAY * (day - 1);
            millisAfterYear = millisAfterYear + addMillis;
            setTimeInMillis(getTimeInMillis() + addMillis + 1);
         *Returns the day of month.
        public int getDayOfMonth()
            int days = (int)(millisAfterYear / MILLIS_IN_DAY);
            int cntr = 0;
            while (days >= daysInMonth[cntr])
                days = days - daysInMonth[cntr];
                cntr++;
            //Internally this class stores dates starting at zero, but i want it to look like it starts at 1.
            return days + 1;
         *Sets the time to the currently selected day at the passed hour on the hour. uses 24 hour clock.
        public void setHour(int hour)
            if (hour < 0 || hour > 23)
                throw new ArrayIndexOutOfBoundsException(hour);
            setDayOfMonth(getDayOfMonth());
            long addMillis = MILLIS_IN_HOUR * hour;
            millisAfterYear = millisAfterYear + addMillis;
            setTimeInMillis(getTimeInMillis() + addMillis);
         *Returns the hour (but not how many minutes past the hour).
        public int getHour()
            long millisAfterDay = millisAfterYear % MILLIS_IN_DAY;
            return (int)(millisAfterDay / MILLIS_IN_HOUR);
         *Set the minutes past the hour. Works 0-59.
        public void setMinute(int minute)
            if (minute < 0 || minute > 59)
                throw new ArrayIndexOutOfBoundsException(minute);
            setHour(getHour());
            long addMillis = MILLIS_IN_MINUTE * minute;
            millisAfterYear = millisAfterYear + addMillis;
            setTimeInMillis(getTimeInMillis() + addMillis);
         *Returns the minutes past the hour, 0-59.
        public int getMinute()
            long millisAfterHour = millisAfterYear % MILLIS_IN_HOUR;
            return (int)(millisAfterHour / MILLIS_IN_MINUTE);
         *Sets the seconds past the minute, 0-59.
        public void setSecond(int second)
            if (second < 0 || second > 59)
                throw new ArrayIndexOutOfBoundsException(second);
            setMinute(getMinute());
            long addMillis = MILLIS_IN_SECOND * second;
            millisAfterYear = millisAfterYear + addMillis;
            setTimeInMillis(getTimeInMillis() + addMillis);
         *Returns the seconds past the minute, 0-59.
        public int getSecond()
            long millisAfterMinute = millisAfterYear % MILLIS_IN_MINUTE;
            return (int)(millisAfterMinute / MILLIS_IN_SECOND);
         *The more commonly seen set method of other date objects. Sets the date/time to 00:00 of the year/month/day passed. Convenience method
         *for setDate(int year, int month, int day, int hour, int minute, int second).
        public void setDate(int year, int month, int day)
            setDate(year, month, day, 0 , 0 , 0);
         *Sets every date/time field.
        public void setDate(int year, int month, int day, int hour, int minute, int second)
            setYear(year);
            setMonth(month);
            setDayOfMonth(day);
            setHour(hour);
            setMinute(minute);
            setSecond(second);
         *Returns yes if the stored date is a leap year. A leap year is every year that is divisible by four unless it is divisible by 100
         *unless it is also divisible by 400.
        public boolean isLeapYear()
            return isLeapYear(this.year);
         *For internal use. Returns if the passed year meets the criteria for a leap year.
        private boolean isLeapYear(int year)
            boolean leapYear = false;
            if (year % 4 == 0)
                if (year % 100 != 0)
                    leapYear = true;
                else if (year % 400 == 0)
                    leapYear = true;
            return leapYear;
         *Returns the difference in milliseconds between the time stored in this object and the millis passed to this method.
        public long getDifferenceInMillis(long millis)
            return getTimeInMillis() - millis;
         *Returns the difference in milliseconds between this date and the date passed to this method.
        public long getDifferenceInMillis(AwesomeDate otherDate)
            return getDifferenceInMillis(otherDate.getTimeInMillis());
         *Designed to be a wrapper method for the getDifferenceInMillis method. This method changes millis into years/days/whatever. Pass
         *the number of milliseconds you have to convert in the first parameter. The second parameter should be the type of denomination you
         *want (year, day, whatever). Use the MILLIS_IN_* fields associated with this object. Also bear in mind when workin with years that
         *some years are leap years, so in extreme cases of differences of 365+ years you may gain/lose a year.
        public static int toGreaterDenom(long millis, long denom)
            return (int)(millis / denom);
         * The first argument is how many of whatever (days, months, years, etc.) to add (use negative numbers to subtract). For the second
         * argument pass one of the MILLIS_IN_* fields. Thus, to add two hours would be
         * <code>
         *      AwesomeDate.adjustDate(2, AwesomeDate.MILLIS_IN_HOUR);
         * </code>
        public void adjustDate(int amount, long typeMillis)
            setTimeInMillis(this.millis + amount * typeMillis);
         *Returns an object of type java.util.Date set to the date/time stored here.
        public java.util.Date toUtilDate()
            long offset = TimeZone.getDefault().getRawOffset();
            return new java.util.Date(getTimeInMillis() +  -1 * offset);
    //        return new java.util.Date(getTimeInMillis());
         *Returns an object of type GregorianCalendar set to the date/time stored here.
        public GregorianCalendar toGregorianCalendar()
            long offset = TimeZone.getDefault().getRawOffset();
            GregorianCalendar cal = new GregorianCalendar();
            cal.setTimeInMillis(getTimeInMillis() - offset);
            return cal;
         *Returns an object of type java.sql.Date set to the date/time stored here.
        public java.sql.Date toSQLDate()
            long offset = TimeZone.getDefault().getRawOffset();
            return new java.sql.Date(getTimeInMillis() - offset);
        /** Format the date  using the string that you pass. Works just like the SimpleDateFormat object. Infact, it uses one! Heres
         *how it works:
         *Letter  Date or Time Component  Presentation  Examples  <br>
         *G  Era designator  Text  AD  <br>
         *y  Year  Year  1996; 96  <br>
         *M  Month in year  Month  July; Jul; 07<br> 
         *w  Week in year  Number  27  <br>
         *W  Week in month  Number  2  <br>
         *D  Day in year  Number  189  <br>
         *d  Day in month  Number  10  <br>
         *F  Day of week in month  Number  2<br> 
         *E  Day in week  Text  Tuesday; Tue  <br>
         *a  Am/pm marker  Text  PM  <br>
         *H  Hour in day (0-23)  Number  0<br> 
         *k  Hour in day (1-24)  Number  24  <br>
         *K  Hour in am/pm (0-11)  Number  0  <br>
         *h  Hour in am/pm (1-12)  Number  12  <br>
         *m  Minute in hour  Number  30  <br>
         *s  Second in minute  Number  55  <br>
         *S  Millisecond  Number  978  <br>
         *z  Time zone  General time zone  Pacific Standard Time; PST; GMT-08:00<br> 
         *Z  Time zone  RFC 822 time zone  -0800  <br>
        public String toFormattedString(String format)
            SimpleDateFormat formattage = new SimpleDateFormat(format);
            return formattage.format(toUtilDate());
         *I overrode the toString method. Now it tells everyone how awesome my AwesomeDate is.
        public String toString()
            String output = "John's Awesome Date!";
            output = output + " Millis: " + getTimeInMillis();
            output = output + " Year: " + getYear();
            output = output + " Month: " + getMonth();
            output = output + " Date: " + getDayOfMonth();
            output = output + " Time: ";
            if (getHour() < 10)
                output = output + "0" + getHour();
            else
                output = output + getHour();
            if (getMinute() < 10)
                output = output + "0" + getMinute();
            else
                output = output + getMinute();
            output = output + " Seconds: " + getSecond();
            return output;
        public static void main(String[] psvm)
            AwesomeDate blah = new AwesomeDate();
            GregorianCalendar blah1 = new GregorianCalendar();
            GregorianCalendar blah2 = new GregorianCalendar();
    }

    The reason Callendar is so complicated is that it is trying to solve a very complicated problem.
    You don't appear to support leap seconds (of which there can be upto 2 in any time interval)
    http://www.timeanddate.com/time/leapseconds.html
    Some of your code will not work for large dates very well (seems to iterate over the years). Try using your date class for astronomical or geological calculations. them big numbers will make your code slow at the moment.
    You don't seem to support timezones or transitory offsets (BST vs GMT). You most definately don't handle changes to timezone offsets that have occured in the past or historical daylight savings time offsets (they have not always been the same)
    The difference between two calendars is a "duration" a duration means nothing unless it is applied to a caledar/date (although you may be able to get away with it if the duration is always stored in millis)

Maybe you are looking for

  • Can you actually search...

    ...dates/events in icloud calendar? I can't seem to find a search facility.

  • My Font Book is missing some fonts??

    Hi, I've upgraded from Tiger to Leopard. Tiger is backed up on a portable drive that is currently plugged into a USB port on my Mac. The following has happened three. I just opened a website and a window opeds (on the Mac not the website) telling me

  • G4 powerbook adapter plugs/tips

    I have had the unfortunate repetitive occasion of seeing the wiring going into the older style G4 powerbook tips gradually get loosened and then break off. I successfully resoldered one of them, but I have at least two others, one of which I tried to

  • CQ61-420US Product ID and Serial numbers are 1234567890. How do I correct?

    On start up Product ID is 1234567890 Warranty start date 00/00/2000 Serial number is [Personal Information Removed] How do I correct? This question was solved. View Solution.

  • Where are my pictures in icloud

    I had to get a new iphone.  All backed up to Icloud...it's been 12 hours and only some of my pictures and videos have downloaded...i went on icloud and don't see my pictures at all.  what's happening?