I'm trying to add the system date with a Label. What is wrong with the code

import java.util.*;
import javax.swing.*;
public class CurrentDateApplet extends JApplet
     Calendar currentCalendar = Calendar.getInstance();
     JLabel dateLabel = new JLabel();
     JPanel mainPanel = new JPanel();
     int dayInteger = currentCalendar.get(Calendar.DATE);
     int monthInteger = currentCalendar.get(Calendar.MONTH)+1;
     int yearInteger = currentCalendar.get(Calendar.YEAR);
     public void init()
          mainPanel.add(dateLabel);
          setContentPane(mainPanel);
          dateLabel.append(currentCalendar.get(Calendar.HOUR) + currentCalendar.get
                    (Calendar.MINUTE);
}

As for what's wrong with the code, it would be easier if you said: it doesn't show the date (it does this instead), it doesn't compile (I get this message) etc.
Anyway I'll assume you want to display the time in a label...
dateLabel.append(currentCalendar.get(Calendar.HOUR) + currentCalendar.get
(Calendar.MINUTE);This won't compile: the parentheses are mismatched, and there is simply no such thing as append(). So we could trydateLabel.setText("" + currentCalendar.get(Calendar.HOUR) + currentCalendar.get(Calendar.MINUTE));This wroks, but looks pretty nasty and it's not how you are supposed to format dates and times. Here's the unofficial party line, nicked from one of jverd's posts:
Calculating Java dates: Take the time to learn how to create and use dates
Formatting a Date Using a Custom Format
Parsing a Date Using a Custom Format
From those links you should be able to find those applicable to times like this: http://www.exampledepot.com/egs/java.text/FormatTime.html
Using this approach you would end up with something like:import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.JApplet;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class CurrentDateApplet extends JApplet
    private Date date;
    private JLabel timeLabel;
    private JPanel mainPanel;
    public void init()
        mainPanel = new JPanel();
        timeLabel = new JLabel();
        mainPanel.add(timeLabel);
        setContentPane(mainPanel);
        date = new Date();
        Format formatter = new SimpleDateFormat("HH:ss a");
        timeLabel.setText(formatter.format(date));
}

Similar Messages

  • HT1688 My iphone 5 won't charge and it's in perfect condition, I dont drop it and it's not cracked. I tried multiple chargers, none of them are damaged and my outlets work with other things so the problem is my phone. What's wrong with it and what should

    My iphone 5 won't charge and it's in perfect condition, I dont drop it and it's not cracked. I tried multiple chargers, none of them are damaged and my outlets work with other things so the problem is my phone. What's wrong with it and what should I do? Please help me I need my phone for work.

    Make sure there's nothing blocking a contact in the charging port of the phone.

  • When on the phone to someone the phone crackles and hangs up so the other person can't hear what is wrong with it? :(

    When on the phone to someone the phone crackles and hangs up so the other person can't hear what is wrong with it? :(

    That iPhone needs to be tested by the techs at an Apple store genius bar to see what is faulty in the hardware.

  • My iMac with Mavericks update does not recognize my brother printer and I cannot even add the printer info in the system preferences printer list.  What is WRONG?

    I had to buy a new printer when I got my Imac and I chose the Brother multifunction inkjet MFCJ470DW.  It worked fine when my Mavericks version was 10.9.1, but after the automatic update to 10.9.2 the computer no longer recognizes the brother, or says it isn't connected, and when I deleted it from printer preferences and attempted to re-enter it as default printer, I cannot even type anything into the list of printers when I press the + sign to add.  What am I doing wrong?  Can someone please tell me even how to add text into the printer preferences list? 

    I had some of the same issues your having, deleted the printer from Printer and Scanner in System Preference.
    What I ended up doing was connecting the printer with a USB cable like it was a new set up, down loaded the drivers from Apple, still did not seem to work, but did a coupel of restarts and the printer was found then I completed the set up.

  • I just installed update version 11.1.4.62.  Now Itunes doesn't recognize my iphone or ipad.  My wife just installed the same version with the same result.  The problem is clearly a problem with itunes.  What's wrong with itunes?

    I was running the previous version of itunes and it worked perfectly.  I just installed the latest version of itunes (version 11.1.4.62) and restarted the PC and now itunes doesn't recognize my iphone or my ipad.  I'm running Windows 8.1 on my pc.  I tried diagnostics to no avail.  The diagnostic didn't recognize either device.  As the directions advised, I closed itunes, disconnected the devices and stopped and restarted the apple  mobile device service,  That didn't work either.  My wife, who also has Windows 8.1, has the same problem.  She installed the new version and it doesn't recognize her devices.
    Until now, itunes has been totally reliable.  I am convinced the problem is with itunes.  Where do I go from here?

    I resolved the issue by doing the following:
    1. Uninstall iTunes and every Apple application (device support and such).
    2. Uninstall bonjour.
    3. Reboot.
    4. Go to Apple and install iTunes.
    It worked.  When I opened iTunes (after reinstalling) it recognized all my devices, music and video.

  • My Iphone 5 is having trouble focusing everytime I am trying to take a picture. Does anyone know what is wrong with it?

    Iphone 5 is having trouble focusing when taking pictures.

    Try This...
    Close All Open Apps... Perform a Reset... Try again...
    Reset  ( No Data will be Lost )
    Press and Hold the Sleep/Wake Button and the Home Button at the Same Time...
    Wait for the Apple logo to Appear...
    Usually takes about 15 - 20 Seconds... ( But can take Longer...)
    Release the Buttons...

  • My App Store is not working and I have tried three different common methods more than once. What is wrong with it?

    I really need help with this because it will load but not update or download any app I have/want. Please help. I do not know what to do.

    Try:
    Can't connect to the iTunes Store
    It could be an Apple problem since other users have been reporting the same problem today.

  • When measuring 6 voltage signals in labview I found that there was a difference in voltage signals in my program but not in the test panel. The test panel is correct. What is wrong with my program?

    My labview program is not displaying equivelent voltages, but labview test panel is. So the computer is seeing the correct signals. My program is displaying a small difference in 3 out of 6 channels. All channels should be equal.

    G'Day Pops,
    You haven't really given us enough to go on - could you please post your VI so we can have a look at it?
    cheers,
    Christopher
    Christopher G. Relf
    Certified LabVIEW Developer
    [email protected]
    Int'l Voicemail & Fax: +61 2 8080 8132
    Aust Voicemail & Fax: (02) 8080 8132
    EULA
    1) This is a private email, and although the views expressed within it may not be purely my own, unless specifically referenced I do not suggest they are necessarily associated with anyone else including, but not limited to, my employer(s).
    2) This email has NOT been scanned for virii - attached file(s), if any, are provided as is. By copying, detaching and/or opening attached files, you agree to indemnify the sender of such responsibility.
    3) B
    ecause e-mail can be altered electronically, the integrity of this communication cannot be guaranteed.
    Copyright © 2004-2015 Christopher G. Relf. Some Rights Reserved. This posting is licensed under a Creative Commons Attribution 2.5 License.

  • NullPointerException while trying to add "WebLogic System Lib." in a classp

    I'm having an error while trying to add WL System Libs in a classpath of an Hibernate configuration.
    // yes, required is Hibernate Tools Eclipse plugin, v3.2.0 GA
    /// available through http://www.hibernate.org/255.html - click on any "download" link
    I first thought it would certainly be an Hibernate Tools bug, but according to the Stack Trace, it might be BEA WLS Tools which is faulty (=> NullPointerException)
    That's why I preferred posting here first, before even issuing a bug report on http://bugzilla.bea.com/
    Steps to reproduce:
    1. Open the "Hibernate" perspective
    2. Create or edit an Hibernate configuration (through the "+" icon or by right-click then "Edit Configuration" on an existing
    3. Go to the "Classpath" tab.
    4. Click "Advanced..." button, then check "Add Library" radio button; select "WebLogic System Libraries" entry and then "Next >".
    5. Error happens in the Eclipse "Error Log" tab and the WebLogic library is not added.
    Details
    Message: "Unhandled event loop exception"
    Exception Stack Trace:
    java.lang.NullPointerException
         at com.bea.workshop.wls.ui.internal.SystemLibrariesContainerPage.initialize(SystemLibrariesContainerPage.java:93)
         at org.eclipse.jdt.internal.ui.wizards.buildpaths.ClasspathContainerWizard.getContainerPage(ClasspathContainerWizard.java:155)
         at org.eclipse.jdt.internal.ui.wizards.buildpaths.ClasspathContainerWizard.getNextPage(ClasspathContainerWizard.java:170)
         at org.eclipse.jface.wizard.WizardPage.getNextPage(WizardPage.java:172)
         at org.eclipse.jface.wizard.WizardDialog.nextPressed(WizardDialog.java:813)
         at org.eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDialog.java:369)
         at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:616)
         at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:227)
         at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
         at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938)
         at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3682)
         at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3293)
         at org.eclipse.jface.window.Window.runEventLoop(Window.java:820)
         at org.eclipse.jface.window.Window.open(Window.java:796)
         at org.eclipse.jdt.internal.ui.wizards.buildpaths.ClasspathContainerWizard.openWizard(ClasspathContainerWizard.java:226)
         at org.eclipse.jdt.ui.wizards.BuildPathDialogAccess.chooseContainerEntries(BuildPathDialogAccess.java:272)
         at org.eclipse.jdt.internal.debug.ui.actions.AddLibraryAction.run(AddLibraryAction.java:39)
         at org.eclipse.jdt.internal.debug.ui.launcher.RuntimeClasspathAdvancedDialog.okPressed(RuntimeClasspathAdvancedDialog.java:156)
         at org.eclipse.jface.dialogs.Dialog.buttonPressed(Dialog.java:464)
         at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:616)
         at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:227)
         at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
         at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938)
         at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3682)
         at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3293)
         at org.eclipse.jface.window.Window.runEventLoop(Window.java:820)
         at org.eclipse.jface.window.Window.open(Window.java:796)
         at org.eclipse.jdt.internal.debug.ui.actions.AddAdvancedAction.run(AddAdvancedAction.java:39)
         at org.eclipse.jdt.internal.debug.ui.actions.RuntimeClasspathAction$1.widgetSelected(RuntimeClasspathAction.java:137)
         at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:227)
         at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
         at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938)
         at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3682)
         at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3293)
         at org.eclipse.jface.window.Window.runEventLoop(Window.java:820)
         at org.eclipse.jface.window.Window.open(Window.java:796)
         at org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationsDialog.open(LaunchConfigurationsDialog.java:1133)
         at org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationPropertiesDialog.open(LaunchConfigurationPropertiesDialog.java:230)
         at org.eclipse.debug.ui.DebugUITools.openLaunchConfigurationPropertiesDialog(DebugUITools.java:429)
         at org.eclipse.debug.ui.DebugUITools.openLaunchConfigurationPropertiesDialog(DebugUITools.java:408)
         at org.hibernate.eclipse.console.actions.EditConsoleConfiguration.edit(EditConsoleConfiguration.java:104)
         at org.hibernate.eclipse.console.actions.EditConsoleConfiguration.doRun(EditConsoleConfiguration.java:71)
         at org.hibernate.eclipse.console.actions.ConsoleConfigurationBasedAction.run(ConsoleConfigurationBasedAction.java:63)
         at org.eclipse.ui.actions.BaseSelectionListenerAction.runWithEvent(BaseSelectionListenerAction.java:168)
         at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:546)
         at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:490)
         at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:402)
         at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
         at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938)
         at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3682)
         at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3293)
         at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2389)
         at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2353)
         at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2219)
         at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:466)
         at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:289)
         at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:461)
         at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
         at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:106)
         at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:169)
         at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:106)
         at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:76)
         at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:363)
         at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:176)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
         at java.lang.reflect.Method.invoke(Unknown Source)
         at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:508)
         at org.eclipse.equinox.launcher.Main.basicRun(Main.java:447)
         at org.eclipse.equinox.launcher.Main.run(Main.java:1173)
    Session data: (empty)
    (copied from another unrelated error - provided for info)
    eclipse.buildId=M20071023-1652
    java.version=1.5.0_14
    java.vendor=Sun Microsystems Inc.
    BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en
    Command-line arguments: -os win32 -ws win32 -arch x86

    Looks like a case that wasn't encountered before. Please go ahead and
    open a bug at http://bugzilla.bea.com?
    Thanks,
    - Konstantin

  • Schedule a report with the system date imbeded in the file name

    Hello,
    Could anyone tell me how I can schedule a crystal report with the system date imbedded in the file name (FileNameYYYYMMDD) through BOE?  When I scheduled the report through BOE, I gave a file name and selected Attach Date Time, but the file name is coming out slightly differently and with the time imbedded as well (FileNameYYYY-MM-DD-HH-MN I think). Is there a way to change the default system date time format in BOE so that the date stamp comes out the way we want it?
    Thanks!

    %SI_STARTTIME% will add the time the report ran too.
    Adding onlt the date will necessarily have to be done via the appropriate SDK.

  • I just made the switch to mac. I am have installed all the new PS6 CC and bridge and I am now trying to add some presets to my  ACR but when I search for the folder to place them it is not there.  From what I researched it says it should be under camera l

    I just made the switch to mac. I am have installed all the new PS6 CC and bridge and I am now trying to add some presets to my  ACR but when I search for the folder to place them it is not there.  From what I researched it says it should be under camera library/application support/adobe/camera raw/settings but I can only get to library/application support/adobe/ and then there are two different camera raw options I have checked both and there are not settings folder. If anyone can help me please thanks

    Apple most likely has the same poor taste that Microsoft does when it come to defaults.  Microsoft likes to hide things like  settings, preset, folders etc from normal users  think the dumb or something else.  If Apple also hide things you will have to  make some system setting changes that will allow Finder to do it job and find it for you.

  • Trying to add sales area data to sold to party in CRM using

    Hi all,
    i am trying to add sales area data to a sold to party business partner and i used the BAPI BAPI_BUPA_FRG0010_ADD. it executes i dont get runtime error but i get the error "invalid sales and distribution area" in return table.
    also i see that the sales area data of the sold to party is not updated after i execute my program
    can anyone tell me what i am missing
    Edited by: jessica sam on Nov 13, 2008 8:17 PM

    hey Rob i dont know if the configuration is done.but if i try to create a sold to party business partner in the screen in CRM i sales area data tab----->sales area, i find the drop down list with the values for sales organization, ditribution channel and division.
    i am able to create a sold to party in CRM and it is replicating in ECC. but if i try to display the sales area data of a sold to party that i created using the function module BAPI_BUPA_FRG0010_GETDETAIL
    it throws me an error saying invalid sales area data.
    Also i find that data is there in CRMM_BUT_LNK0021, CRMM_BUT_LNK0031 tables but not even one entry in CRMM_BUT_LNK0011
    Also i find that data is there in CRMM_BUT_SET0020, CRMM_BUT_SET0030 tables but not even one entry in CRMM_BUT_SET0010
    is some thing missing in functional configuration. the CRM guy did an intial upload from R3 and brought the sales organization to CRM.

  • The activity procedure date must be larger than the system date in VA42

    Please Help me...... I am trying to update the Contract End Date in VA42 but it is not updating and through an error message
    ''The activity procedure date must be larger than the system date''
    please help me to solve the issue....
    Thanks & Regards
    Shakeel

    Shakeel Ahmed Mohammed
    Please update how you solved so that it will be helpful to others who face similar issue.
    G. Lakshmipathi

  • Cannot install AIR application when the system date is set beyond 10/31/2017

    I created a native time-stamped installer for an AIR application. While testing the installer with different system dates, I noticed that the installer does not work when the system date is set beyond 10/31/2017. I tested the same with a self-signed certificate as well as a Verisign certificate and found the behaviour to be consistent. Why does the installer stop working after this date?

    Thanks very much for keeping this issue alive.
    Let me restate the issue:
    We have a AIR 2.0.4.13090 sidecar application. Installing the application for the very first time seems to work. Any uninstall or update after that runs into issues on the problematic Windows 7 64 bit machine. The installer logs all point the finger to Windows Installer having problems writing to the temp directory.
    We've gone through many, many things trying to resolve this, including resetting administrative access to the temp directory and flushing the temp directory out entirely. I'm reporting this news secondhand, so it's not possible for me to directly relate the exact measures taken, step-by-step. The ONLY thing that reliably worked for running and installing updates on this AIR application was the following:
    1) Create a new administrative level user.
    2) Log in with that user.
    3) Disable firewalls.
    4) Run the updater.
    5) Log back in as normal user, delete temporary user.
    if the user account created in step 1 is not deleted in step 5 and is used to attempt a further update or uninstall, it will fail. This seems to tell me that AIR is able to utilize the temp folder via Windows Installer correctly only once. After that, it dirties this directory somehow and is unable to use/write to it, and subsequent uninstalls/updates fail with error 0.
    Again, the failure all show msi issues writing to the temp directory. They result in an "Error 0" alert dialog in AIR.

  • N82 Self change the system date!!!

    Hi to all....let's get to the problem at once....
    my Nokia N82 was working flawlessly with the v30 firmware BUT when I upgraded to v31 it started to change the system date!!!!! I've search for a parameter in the menus but .... no such parameter...) it adds 2 days in the system date in many occasions.... I thing this is a mega-bug.... please tell me if anyone else have this problem.

    I'm having the same issue, after upgrading firmware to v31.0.016 the system date "jumps" two days forward every morning if I set a workday-alarm and then switch off the phone. After the alarm rings I turn on the phone and it shows the correct date, but a few minutes later it jumps 2 days forward.
    Because of this bug all of the services connected with system date (agenda, calendar, alarm, memo, reminder, calls register, ...) don't work correctly and are almost unuseful unless you manually correct the system date every morning.
    I'm not going to leave the phone on (not even in offline mode) all night long as a workaround, because I paid lots of money for a working smartphone, and it's not working correctly now.
    I reported the issue to Nokia, I'll let you know if they will suggest any solution.

Maybe you are looking for