How do I go about adding my own method to the class Calendar?

I want to add a method to the class Calendar that will parse a string and set it's date and time with what it parsed from the string. I allready have the parsing code written but I want to know how I can add this to the Calendar class.
I thought I could extend the Calendar class with something like this...
public abstract class myCalendar extends Calendar{
    public myCalendar() {
    public int parseDaytime(String givenLine){
        int flag = 1; //used to report errors
     //do some parsing
        return flag;
}But then in my main program I cannot use any of the Calendar methods...
            myCalendar timeFromServer;
         timeFromServer = timeFromServer.getInstance(); //error, it won't let me use the Calendar methods
            if(timeFromServer.parseDaytime(readFromServer) == 0){
                System.out.println("Error parsing time data from server.");
            }

Aside from my original question, I do not understand why extending Java classes is over kill. You listed the example of extending Thread as a big one. Everytime I create a worker Thread the class I create extends Threads because thats what I learned from every example I have looked at.
Okay. I should be good at writing this by now, so here goes....
You only get to inherit from a superclass once. You can implement as many interfaces as desired. As such, whenever you inherit from a class, you are limiting any other possible inheritance from another superclass. So, all things being equal, you should prefer interfaces to inheritance.
This is why java.lang.Runnable exists. There is almost never a reason to extend Thread. The normal 'is a' test is somewhat misleading in this case when determining whether to extend Thread or not. You may say, "My class is threaded, so I should extend Thread." However, while there exists an 'is a' relationship here, it is not salient. Your class undoubtedly is something else as well. The fact that it is threaded should be thought of as an aspect of feature of your class.
So, in general, you should implement Runnable and not extend Thread.
public class Foo implements Runnable {
   final public void run() {
       // cool asynchronous code goes here
public class FooUser {
   private void someMethod() {
       Thread thread = new Thread(new Foo());
       thread.start();
}- Saish

Similar Messages

  • I just really need to know... After desigining my UX, how do I go about adding the image into ADOBE FLASH BUILDER to script on top of it?

    I just really need to know... After desigining my UX, how do I go about adding the image into ADOBE FLASH BUILDER to script on top of it?
    Any and all advice is welcome.

    Do you have different versions of the graphic novel pages, or is there just one version of the page? If there is one version, can you crop into the page without losing anything important?
    I would guess that there is one version, and that cropping into the page will lose something important. If that's the case, here's how I would handle it:
    Make a stage that is 14:9. The size doesn't matter, but 1400x900 could be a good starting point.
    Put down a background texture that fits well with the look of the other images. Make that fill the 1400x900 stage.
    Place your page graphics so that they are within the center 1200x788 area of the stage.
    Set the stage scalemode to "noBorder".
    You now have a layout that will work on all devices, as narrow as iPad, and as wide as iPhone 5. All without any code. On the widest devices you'll see a bit of your background pattern to the left and right of the page graphic. On the narrowest devices you'll see a bit of background pattern above and below the page graphic. But you won't lose sight of anything important.

  • How would I go about adding multiple rectangles using the same lines of code?

    How would I go about adding multiple rectangles using the same lines of code? I would prefer to just run through a set of code every time I need a polygon. If I just have to create multiple polygon adding statements that's fine but I'd prefer just 1.

    >>How would I go about adding multiple rectangles using the same lines of code?
    You could create a method that creates and returns x number of Rectangle elements:
    public IEnumerable<Rectangle> CreateRectangles(int numberOfRectsToCreate)
    for (int i = 0; i < numberOfRectsToCreate; ++i)
    Rectangle rect = new Rectangle();
    rect.Fill = Brushes.Blue;
    rect.Width = 100;
    rect.Height = 100;
    yield return rect;
    ..and then call this method from anywhere in your code:
    IEnumerable<Rectangle> rects = CreateRectangles(5);
    foreach (Rectangle rect in rects)
    //add to StackPanel or do whatever with the Rectangle elements:
    yourStackPanel.Children.Add(rect);
    >>If I just have to create multiple polygon adding statements that's fine but I'd prefer just 1.
    When adding Point objects to a Polygon you can only add one per call to the Add method but you could call the Add method inside a loop, e.g:
    for(int i = 0; i < 10; ++i)
    //add to StackPanel or do whatever with the Rectangle elements:
    Polygon p = new Polygon();
    p.Points.Add(new Point());
    Please remember to close your threads by marking helpful posts as answer and then start a new thread if you have a new question. Please don't post several questions in the same thread.

  • Hello! I just purchased a new 27" iMac on Nov. 3. It can with Mountain Lion preinstalled, which I upgraded to Mavericks. How do i go about getting my free version of the iWork suite? Thanks!

    Hello! I just purchased (Nov. 3, 2013) a new 27' iMac. It came with Mountain Lion preinstalled, which I upgraded to Mavericks. How do I go about getting my free version of the iWork suite? Thank you.

    djg007 wrote:
    Hello! I just purchased (Nov. 3, 2013) a new 27' iMac. It came with Mountain Lion preinstalled, which I upgraded to Mavericks. How do I go about getting my free version of the iWork suite? Thank you.
    You have 90 days of free AppleCare telephone support, click AppleCare Contact Info for the number on your part of the planet and call them, they will give you instructions on how to get your license of the iWorks apps.

  • How do I go about embedding a jquery plugin into the building process of Adobe Muse?

    How do I go about embedding a jquery plugin into the building process of Adobe Muse?

    Many of the "Edge" fonts offered in Muse for web font use are available as open source fonts from Google or other sites like Font Squirrel. For example, a company may want to use the Exo typeface in their logo. You can use Exo as a web font within a web site created in Muse. For general graphics work, like creating a logo and other branding work, the same typeface can be installed as a system font from the sources I mentioned.
    The newest version of Muse will now allow you to use SVG graphics -a vector-based graphics format for the web. SVG objects can be scaled to any size without showing pixel jaggies. You can create vector-based type objects using any system font in Adobe Illustrator or other similar applications capable of saving SVG. Within Illustrator you can creatively manipulate those type objects, or do subtle things like adjusting letter spacing, then output it as an SVG image. I don't particularly care for the default letter spacing of many web fonts, so SVG is a fairly decent alternative.
    Most new web browsers support SVG properly. Old versions of Internet Explorer (8 and earlier) and some older mobile web browsers don't support SVG without user-installed plug-ins. Those web browsers are disappearing quickly.

  • How to handle exception thrown in standard bo method in the workflow design

    Hi Experts
        how to handle exception thrown from standard bo method in the workflow design. For example, bo BUS2032, METHOD confirm. If the user cancel it, it will throw exception. In the workflow, how to catch this exception and add corresponding steps in the workflow.

    @jrockman li
    Try to implement the logic that what ever you are performing in the BO mehtod in a FM and in the FM you have tab with name EXECPTIONS define the execption in that tab.Now in the BO method you call this FM  and if the exception occurs by using RAISE you can raise the exception in the FM and based on the number of exceptions your sy-subrc value will be set
    so when sys-subrc is not eq 0 then pass a value back t the workflow container., I think this will work.
    a sample Snippet for understanding purpose
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
        filename         = <path>
        filetype         = 'ASC'
      IMPORTING
        filelength       = lv_len
      TABLES
        data_tab         = l_txt_tab
      EXCEPTIONS
        file_write_error = 1          " If this Exception occurs
        invalid_type     = 2
        no_authority     = 3
        unknown_error    = 4
        OTHERS           = 10.
    CASE sy-subrc.
      WHEN 1. " SY-SUBRC value will be 1 then,
          " Pass or set the value back to the workflow conatiner element
    ENDCASE.

  • How to find the arguments of a static method from the class file

    Hi,all !
    How to find the arguments of a static method from the class file? for example, when we meet a bytecode "invokestatic", how can I know the arguments of this static method?

    Hi,all !
    How to find the arguments of a static method from the
    class file? for example, when we meet a bytecode
    "invokestatic", how can I know the arguments of this
    static method?You mean
    1. The values?
    2. Argument names?
    3. Argument signatures.
    I would suppose for the last that the easiest way would be to parse the signature string.
    The first is not possible - not from the class file.
    The second is only in the debug information stored in the optional part of the class file. And figuring out the format for that is going to be a problem.

  • I have "ghost" events on my printed calendars repeating daily after the original event. How can I delete these as they only appear on the printed calendars and not on the on screen version?

    I have "ghost" events on my printed calendars repeating daily after the original event. How can I delete these as they only appear on the printed calendars and not on the on screen version?

    I had a similar situation.  My credit card bill shows a charge on Sept 8 and Sept 9, both for $55.99.  I called Apple but they said that I was the victim of identity theft so I cancelled my credit card.  They have not refunded my money.

  • HT1349 How do I go about adding IOS 5.0 to my iPad so I can upgrade Pages.

    How do I upgrade Pages?  It says I need to have IOS 5.0.  How do I go about doing that?

    First of all you must be running iTunes 10.5 on your computer if you want to update to iOS 5.  The very latest version is 10.5.3 so if you are not running 10.5 download and install it.
    Then connect your iPad to your computer, launch iTunes, click on the iPad name on the left under devices and then click on the Check for Update Button in the Summary pane of iTunes on the right.
    ITunes should prompt you to update when the iPad is connected and iTunes is running, but you can click on the button to start the upgrade process to iOS 5 on your own if necessary.

  • I have just bought a new laptop, how do I go about adding iTunes to it and transferring everything from my old laptop?

    Hello -
    I have just bought a new laptop with Windows 8 and I would like to know how I go about adding iTunes to it and transferring all my information to this laptop?  I would appreciate any help possible.
    Thanks
    Jennie

    MegsiPhone wrote:
    This user tip may help too
    Syncing to a "New" Computer or replacing a "crashed" Hard Drive
    I must tell you, I am in the situation that MegsiPhone described and I am confused as to what to do.  Here is what I have done thus far:
    1.  I installed iTunes on my new computer, I wen't ahead and set up a new library file locally, and pointed to my NAS for all the music and movies file in edit>advanced.  From what I recall, when I did I can remember getting a whole bunch of messages about apps, new versions, overwriting.  I don't recall, regadless I dismissed each on and did not override.  Anyway, that's all done now.
    2.  I can tell you that I used to back up three iPhones and an iPod touch to my old PC.  There is a mixture of 4 iTunes ID's with various app purchases, it seems a mess. 
    3.  I did plug my phone in, it gave me the error message about syncing only to one computer.  Then I did a back-up and a sync.  I know it did not work right because it took a matter of seconds when I know it should take a lot longer.  Anyway, as a safeguard I am using iCloud back-up for now before I do anything else.
    So, what do I do now to make this all right?  I would like to be able to sync mine and my wife's iPhone to the computer.  Should I not bother and just keep my back-up in the cloud and are there disadvantages to this?  For my son's iPhone, I can let him back-up to the old computer, I would assume that would remain good and I would not have any issues.  Should I erase the back-up on my new computer, erase the appss or whatever and start from scratch?  Kind of not sure how to handle, please help.

  • How to interact an input file with other methods in a class?

    I have to write a class name FileDisplay with methods:
    1. Constructor: take the name of a file as an argument
    2. displayContents: display the entire contents of the file
    when I tried to create a BufferedReader file variable, I have encountered an error about IOException. Then I tried to put this variable to the constructor. The problem didn't occur anymore but another problem has occured. The displayContents can not recognize the BufferedReader file variable because it was created in the block of constructor, not related to displayContents at all!
    I wonder how I can solve this problem? Anyone has any idea? Thank you ./.

    Well, I suppose your displayContents() method could allow the IOException to bubble up to its invoking method via throws.
    I assume that method is the constructor which, in turn, will need to do the same thing.
    Then, whatever method invokes that constructor will also need to do the same thing.
    Not really good style.
    Of course, if you haven't yet covered the throws clause, then, I think you're screwed.
    It sounds like exception handling should have been discussed before this assignment.

  • Error while adding a new method to the Session Bean

    Hello everyone. I'm using jdev 11g, ejb, jpa & jsf. Everything works fine. But when I try to add a custom method to the Session Bean, I'm having an error.
    Here is my steps:
    1) I added a new method to SessionBean.java. Something like this:
    public void Hello() {
    System.out.println("Hello!");
    2) Then using Structure palette I exposed this method through Local interface and created data control
    3) Finally, I made a command button binded to this method (just droped it from DataControls.dcx to my page)
    When I start the page and click the button, I'm having the following error:
    Error 500--Internal Server Error
    javax.faces.el.EvaluationException: Method not found: Hello.execute(javax.faces.event.ActionEvent)
         at org.apache.myfaces.trinidadinternal.taglib.util.MethodExpressionMethodBinding.invoke(MethodExpressionMethodBinding.java:58)
         at org.apache.myfaces.trinidad.component.UIXComponentBase.broadcastToMethodBinding(UIXComponentBase.java:1227)
         at org.apache.myfaces.trinidad.component.UIXCommand.broadcast(UIXCommand.java:183)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent$1.run(ContextSwitchingComponent.java:70)
    ... (I've truncated the log because there is nothing important in the missing part)

    Yes, I have binding in the page def. Everything is correct there:
    <methodAction id="Hello" RequiresUpdateModel="true" Action="invokeMethod"
    MethodName="Hello" IsViewObjectMethod="false"
    DataControl="PriceServiceLocal"
    InstanceName="PriceServiceLocal.dataProvider"/>
    I've droped the method from the Data Controls panel

  • How would I go about compiling my own multilib GCC?

    Hello, as the topic says, how would I compile my own multilib GCC? I realize there is one on the AUR, but it is version 4.4.0, which has issues with compiling FFMpeg and MPlayer(both of which I compile daily), and the fact that the pkgbuild has to be manually updated in a few areas to work in the first place. I'm thinking about updating the PKGBUILD myself, actually(well creating a parallel build in any case, because the author hasn't actually orphaned it, but he seems to have disappeared).
    I've found a few documents on the subject but they are distro specific, or use scripts. I don't want to be a script kiddie, I want to know what the "base" configure parameters are for setting one up. I can figure out the rest.
    Slackware scripts link here.
    -What ./configure parameters create a multi-lib system? What specifies the multilib compile to be 32-bit and 64-bit?(I read that sometimes people use multi-lib for other features so I want to make sure it's 32-bit and 64-bit, not something else)
    -How would I make this build compatible with the /opt/lib32 system that Arch users like to use?
    -Do I only need to compile binutils, glibc, and gcc? And lastly, does this replace the "regular" gcc on the system?(aka if I created a PKGBUILD for this, would gcc still be named gcc or would it be renamed gcc-multilib and have it's own directories for libs)
    Last edited by MP2E (2009-10-01 01:03:40)

    I'd start by going here:
    http://aur.archlinux.org/packages.php?ID=28545

  • I was wondering about an app that I had on a previous PC located in the "Tools" menu, I would go in to it and submit surveys about Firefox, my question is, what is the name of it and how do I go about adding it to the Firefox that I have on my new PC?

    I had this about 2 weeks ago but don't remember how I got it, it came with the download of 7.0 I think.

    The name of it is Test pilot.
    For more information and download
    https://testpilot.mozillalabs.com/

  • How about adding a meta tag to the index file.....

    This is another way to get verified with Google and other search engines. Does anyone know a way that you could add a meta tag to the index file generated by iweb??
    Thanks for any help....Matt
    http://www.want2takecredit.com

    I'm glad it worked. Nevertheless you might think of uploading an html file as well. The index.html sometimes gets overwritten by iweb, thus the meta-tag would disappear and you would have to do it again. The html file instead stays where it is.
    Here's how to procede:
    When they will ask you to verify that it really is your website. “Choose verification method” select “Upload an HTML file” and now you will have to build that verification file (here’s a How-to by Roddy).
    1. Go to your applications folder and launch Text Edit.
    2. Don't put anything on the blank page.
    3. Select File/Save As.
    4. In the popup window "Save As" box enter your Google number (something like google05a23d347cXXXXXX )
    5. In the "Where" box select desktop.
    6. In "File Format" menu select HTML.
    7. Click "Save".
    8. A file will appear on your desktop called google05a23d347cXXXXXX.html
    9. This is what you upload to your server or iDisk.
    Upload that file to your main folder on your server so that it will be http://www.yoururl.com/google05a23d347cXXXXXX.html (not in the subfolder of the Sites folder named with the title of your site...*).
    For .Mac go to the Finder menu and select Go/iDisk/My iDisk/ or hit SchiftCommand(Apple)i and then go to /Web/Sites/. Drop your file into the "Sites" folder
    Entering: http://web.mac.com/username/google05a23d347cXXXXXX.html in your browser should bring up this file. If it doesn’t you placed the file in the wrong location.
    Entering: http://yourbaseurl.com/google05a23d347cXXXXXX.html in your browser should bring up this file. If it doesn’t you placed the file in the wrong location.
    Regards,
    Cédric
    +I just noticed your other posts on the forum and that you got it solved I'll leave the explanation for other people wondering and stumbling over the thread+

Maybe you are looking for

  • Can not get data from actionscript db operation class?

    DBOperation.as: import flash.events.*; import flash.net.NetConnection; import flash.net.ObjectEncoding; import flash.net.Responder; import mx.collections.ArrayCollection; import mx.controls.List; import mx.rpc.events.ResultEvent; import mx.collection

  • Apps and Game center

    Hi I really need help and i'm kind of new to this site so sorry if i mess some stuff up. So anyway, i used to have an ipod touch 2.5 version and i made a game center account and got many apps. However just in december I bought a new ipod touch 5th ge

  • Screen brightens intensely, quickly, hangs for a few minutes

    My Macbook Pro screen brightens intensely, becoming very very bright, and the notebook becomes hot, hangs for around 2 minutes before getting back to normal. This is a Macbook Pro 2009, running Mavericks. It was on Mountain Lion when this problem occ

  • Remote won't pair up

    Previously the apple remote worked. Now why won't my apple remote pair up with the ATV but my iphone remote app will work? I've tried all the trouble shooting tips but with no luck. Could a bad battery affect this? Thanks.

  • Direct X and X-Fi quest

    Does the X-fi need to run with DirectX 9. For instance, if your playing a game. Does the game need to be running in DX9. Thanks.