The static field should be accessed in a static way

Hello,
I am developing a java app in eclipse and I am getting the error message:
The static field Calendar.DAY_OF_WEEK should be accessed in a static way
I am trying to get the first day of the first week in the current month, here is my code:
GregorianCalendar firstDayOfThisMonthCalendar = new GregorianCalendar(Calendar.YEAR, Calendar.MONTH, 1);
int firstDayOfThisMonth = firstDayOfThisMonthCalendar.DAY_OF_WEEK;I though the problem was that I'm supposed to write the code like this:
firstDayOfThisMonthCalendar.get(Calendar.DAY_OF_WEEK); but then I get the wrong value back

That's what I critice about u people, always ready to
complain, It's not complaining. It's pointing out problems with your code. You should thank him.
but do u put the code in here the way that
someone could read it ? Easy to say 'use
simpleDateFormat. Oh, careful, January returns 0, not
1'.Using SimpleDateFormat is an easier and more correct way to do it. Trying to use the numerical value of the month constants is incorrect coding. You should thank him for educating you.
Why can't u write the code in here so there's no
chance that somebody will ask again.Such code is not possible. No matter what code you write, somebody can misunderstand it.
If you write the code correctly--using SimpleDateFormat--then the code will be correct (which is the most important criteria) and clear (which is important, but not as important as correctness).
But if you prefer to think that your way is always perfect and are afraid to admit your mistakes and learn from them, that's your prerogative.

Similar Messages

  • Static field should be accessed in a static way

    I am getting the following warning message: static field should be accessed in a static way. What does it mean?
    thanks.

    Below is the code. I'm getting the "warning" in the Waiter class on the statement: this.r = r;
    public class Threads {
         public Threads() {
              super();
              System.out.println("==> Threads.constructor");
         public static void main(String args[]){
              System.out.println("==> main");
              Threads t = new Threads();
              Rendezvous r = new Rendezvous();
              Waiter w1 = new Waiter(r);w1.start();
              Waiter w2 = new Waiter(r);w2.start();
              Waiter w3 = new Waiter(r);w3.start();
              new Waiter(r).start();
              new Waiter(r).start();
              new Waiter(r).start();
              new Waiter(r).start();
              Waiter w4 = new Waiter(r);w4.start();
              Waiter w5 = new Waiter(r);w5.start();
              Waiter w6 = new Waiter(r);w6.start();
              System.out.println("==> main done");
         static class Rendezvous{
              private static int ri = -1;
              public synchronized void doWait(Waiter w){  
                   System.out.println("==> doWait - sNum="+w.serialNum+",tries="+w.numTries+" name="+Thread.currentThread().getName());
                   while (w.numTries < 5){
                        notifyAll();
                        w.numTries++;
                        System.out.println("==> before wait()- sNum="+w.serialNum+",tries="+w.numTries);
                        try {wait();} catch (InterruptedException e){}
                        System.out.println("==> after wait() - sNum="+w.serialNum+",tries="+w.numTries);
                   } //end-while
              } //end-doWait()
              public void doNotify(){
                   notify();
         } //end-Rendezvous-class
         static class Waiter extends Thread{
              private static int counter = 1000;
              private static Rendezvous r;
              public int serialNum;
              public int numTries = 0;
              public Waiter(Rendezvous r){
                   this.r = r;
                   serialNum = counter++;
                   System.out.println("==> Waiter.counstructor:sNnum="+serialNum+" name="+Thread.currentThread().getName());
              public void run(){
                   System.out.println("==> Waiter.run():" + serialNum+" name="+Thread.currentThread().getName());
                   r.doWait(this);

  • Is the instance fields have private accessibility in String class?

    Is the instance fields have private accessibility in an immutable class, such as the String class?
    also Could any one answer the following question,
    (This is the question I got in written exam for job recruitment)
    "Invoking a method can represent a significant amount of overhead in a program; as such, some compilers will perform an optimization called "method inlining." This optimization will remove a method call by copying the code inside the method into the calling method."
    Referring to the text above, which one of these statements is true?
    Choice 1 The performance benefits should be balanced against the increased chance of a RuntimeException.
    Choice 2 It allows the use of getter and setter methods to execute nearly as fast as direct access to member variables.
    Choice 3 This optimization will only occur if the relevant methods are declared volatile.
    Choice 4 The developer of inlined methods must copy and paste the code that is to be inlined into another method.
    Choice 5 It prevents code from executing in a way that follows object-oriented encapsulation.

    Sarwan_Gres wrote:
    Is the instance fields have private accessibility in an immutable class, such as the String class?Usually, but not always.
    "Invoking a method can represent a significant amount of overhead in a program; as such, some compilers will perform an optimization called "method inlining." This optimization will remove a method call by copying the code inside the method into the calling method."The java compiler does not inline methods so this is not relevant to Java. (The JVM does inline methods) The java compiler does inline constants known at compile time but it is a feature causes more trouble than good IMHO.

  • Is it okay if i leave the battery charges all the time or should i charge in a special way??

    is it okay if i leave the battery charges all the time or should i charge in a special way??

    About Batteries in Modern Apple Laptops
    Apple - Batteries - Notebooks
    Extending the Life of Your Laptop Battery
    Apple - Batteries
    Determining Battery Cycle Count
    Calibrating your computer's battery for best performance
    MacBook and MacBook Pro- Mac reduces processor speed when battery is removed while operating from an A-C adaptor
    Battery University

  • The decimal field should accept 0.00 as the input and generate the XML

    Hi Experts,
      I have one requirement. I need to display the field which take 0.00 as the input and that field should come in the output XML. This field of type decimal. I m using sender proxy. Im populating the value 0.00 to this decimal field, But the proxy is not producing this field in the output XML. Plz suggest me.
    Regards,
    Rama

    HI Ravi,
    It is accepting the input as 0.00. But i want it as decimal.
    Can u explian what is the difference between these two types decimal and string.
    It should take the input values in the decimal format. ll it take?
    Regards,
    Rama

  • How do I change the genre for a specific song?  In the past, I just had to double click on the genre field entry.  That no longer works.

    How do  change the title of a song or its genre?

    You should be able to edit any of a song's metadata elements (including title and genre) using right-click > Get Info.  In the new iTunes 12 dialog, the Genre field should allow you to type in a genre or select from a dropdown (which offers a combination of iTunes' built-in genres + those you've defined yourself):
    If you SHIFT right-click > Get Info you can also access the "old style" dialog and enter the genre there.
    Are you unable to enter the genre, or having done so is the value held by iTunes not being updated?  If the latter, then you may have an issue with the permissions on your media files or the files may be set to read-only.

  • What key fields should i set in DSO extracting data from 2LIS_02_ITM

    hi experts
    i extract data from 2LIS_02_ITM into a DSO, i know the DSO isn't a must, becoz the 2LIS_02_ITM delta type is ABR, but i want to keep the info in change log.
    so, what the key fields should i set in the dso? just ebeln and ebelp is enough?
    hunger for ur advice and thanks a lot!

    If you extract ITM toa DSO you cannot maintain a log of every change....the data will come ....but when the data must be activated the reference of the ebelp ebeln will remain only a single record....if you want to maintain all the data you must create another field in extractor with you can difference all the changes for one single ebelp ebeln...
    Regards

  • Records not displayed in the WGBEZ field in H_T023_MEPO search help.

    Hello Friends,
    I have created the search help exit , in that based on the LREF3 , we have to fetch the materail groups.
    1.I have written the code in the exit , in the search help exit tables parameter record_tab , the data is coming correctly
    but when we run  search help, the description field is not getting displayed.
    I have shift 2-3 places left side as well but the description is not displayed correctly.
    So how can we get the description field filled.
    2. We want that the LREF3 field should come in the selection screen of the dialog box, so that user can enter the values in it.(dialog with value restriction) so i have added LREF3 field in the search help parameters but i want that
    this field should not be displayed in the results of search help . Only materail group and its description gets displayed.
    So can we achieve the same.
    Thanks to provide answers for my above two questions.

    Hi
    Please go through the related pointers ->
    The OSS note 672960 has already indicated you need to use BADI to address it.
    For Search criteria
    You can also use user-defined fields as search criteria. To do this, you have to set fields XINPUT and XDISPLAY to 'X' in table ET_FIELDS for the fields you want to use in BADI BBP_CUF_BADI_2 in method MODIFY_SCREEN. The fields defined this way are displayed if you choose the 'Extended search' link.
    Re: Custom field in Create Bid Invitation..
    Re: Search Help for Purchasing Group..
    Re: urgent help request - How to add custom fields to  header BID.
    Re: New Screen with table control information in Process Bid Invitation
    Do let me know.
    Regards
    - Atul

  • US iBooks Store should have access to ALL books worldwide

    The US is very rich in cultures. For instance it has a very big Latin American population. The iBooks store should have access to the Spanish books sold in Spanish countries so that this portion of US citizens can read books in their native language. The same goes for every other culture in the US. That's why I'm saying that the US iBooks Store should have access to ALL the libraries in the world of iBooks Stores. Thanks.

    To expand on Tamara's answer a little, the publishing industry (books, music, movies, etc) is not a world-wide monolith. Each country has its own copyright laws which sometimes are quite different from even countries bordering it. This has led to publishers having many subsidiaries and/or working agreements with local publishers. A British author doesn't need to have his/her work translated (which adds its own copyright issues to the meld) but still will require both a US and a UK publisher for the book to be published in both countries. It isn't just a simple matter of lots of books being printed and then shipping some of them across the ocean.
    This mess has existed for a very long time and Apple can't just wave a wand and make it go away.

  • Current Date in the Text Field

    Hi,
    I have got a requirement where i have one text field and one data/time field. Once we select the date from the date field, the date selected in the date field should be reflected in text field in the format DD.MM.YY along with some other text.
    for example,
    if we select date as 03/02/2009 - Date Field, we should get it as
    Today is (date with format DD.MM.YY)

    On the exit of the Date field write the javascript code:
    TextField.rawValue = "Today is " + this.rawValue

  • Need to change the LOV field based on checked box selection in OAF page

    Dear ALL,
    I have a requirement as below:
    I have a custom OAF page having a lov  field which is mandatory, a check box and a two text fields.
    So based on LOV value selection i am defaulting two text field value automatically.
    So my requirement is when user selects the check box automatically the LOV field should be non mandatory and user can insert in values to the lov field and text field and submit it.
    SO basically based on check box field selection i need to make the lov field in such a way it should accept all the values what user enters instead of check the query added in VO behind the LOV.
    Please suggest me some pointers to achieve this requirement.
    Thanks
    Deb

    hi,
    in PFR use:
    if ("checkevent".equals(pageContext.getParameter(EVENT_PARAM))) 
                     HashMap hashMap = new HashMap();
                     String checkboxval=pageContext.getParameter("item2");
                  hashMap.put("checkboxval",checkboxval);
                    pageContext.setForwardURLToCurrentPage(hashMap ,
                    true, // retain the AM
                    OAWebBeanConstants.ADD_BREAD_CRUMB_NO,
                    OAWebBeanConstants.IGNORE_MESSAGES);
    and in PR use:
    if((pageContext.getParameter("checkboxval'))!=null)
    OAMessageLovInputBean lovInputBean=(OAMessageLovInputBean)webBean.findIndexedChildRecursive("item3");
          lovInputBean.setRequired("false");
    try it
    Regards
    Mahesh

  • How do you set the from field in mail to be one of two addresses?

    I have two email addresses.  How do I set up mail so I select which of the addresses goes in the from field?

    The From field should include a drop down menu from which you chose the address you want to ue for that message.

  • How to use the "Flash Field"?

    Hi Everyone,
    I'm trying to figure out how to use the new "Flash Field" inside my form.
    The form we are working on required the user to interact with the "Flash Field" (i.e., click on the bar on a bar-chart) and the "Flash Field" should return some value (defined in the Flash logic) should be returned to the host (the PDF form) as the FlashField.rawValue, for example.
    BTW: The SWF object that is consumed by the "Flash Field" is built by the Flash Builder latest edition (4.5). So we do have a total control on the logic inside the SWF project.
    The Q here is: What is the possibility to modify my code inside my Flash project so it can expose the SWF object computed value to the rawValue property of the Flash Field?
    Appreciating your collaboration....
    BR,
    Yasser

    Hi,
    Have a look at the Flash object Reference Card and the Flash object examples here: http://assure.ly/rqCuEn.
    Hope that helps,
    Niall

  • How to Hide the Parameter field at run time....

    Hi,
    I have a parameter field which behaves differently depending on the User logged in.
    It has the LOV coming from following SQL.
    SELECT customer_name FROM Cust_mast;
    If the user = 'INTERNAL' then the Where clause will be
    WHERE cust_id in('DELL', 'SBC', 'BANK')
    Else there will be no WHERE clause or the parameter field
    should be hidden in the parameter form.
    So my questions are:
    1) How to hide the Parameter field during Run time?
    OR OR OR
    2) How to change the LOV select statement during Run time?
    Thanks.
    Ram.

    Hi Ram,
    Is there any way to play with the sql query SELECT using DECODE ?I'm not sure of this part, maybe someone else can suggest a way.
    However, what you want can be done in 2 other ways:
    1. Build 2 reports. Both reports will just be duplicates of each other, only difference being that the 'LoV where clause' will be different. Now you can fire the appropriate report in many ways. For example, if the customer is alreay logged inside your custom application, and therefore you already know whether the user is internal of external, you can design your button or link which launches the report to contain logic such that one of the 2 reports is fired depending on who the user is.
    1. Use a JSP parameter form, not a paper parameter form In this case, just build an HTML parameter form in the web source of your report. Use Java logic to populate the LoV drop-down list. When you have to launch the final report, just launch the paper-layout of the report. For example (you will have to modify this):
    <form action="http://machine:port/reports/rwservlet?report=ParamForm.jsp+..." name="First" method="post">
    <select name="selected_customer" onChange="First.submit()" >
    <option value="">Choose a Customer Name
    <rw:foreach id="G_cust_id" src="G_cust_id">
         <rw:getValue id="myCustId" src="CUSTOMER_ID"/>
    <rw:getValue id="myCustName" src="CUSTOMER_NAME"/>
    <option value="<%=myCustId%>"><%=myCustName%>
    </rw:foreach>
    </select>
    </form>
    In the code above, you will have to make sure that your report's data model defines 2 CUSTOMER_ID's (like CUSTOMER_ID_INT and CUSTOMER_ID_EXT). These 2 will be internal and external Cust ID's. Use Java logic to show one of them.
    Navneet.

  • BDC date field should be blank

    I am creating a bdc - the date field should be blank.
    My logic is if input-field ne '0'.
      if w_ausbs ne '00000000'.
          PERFORM bdc_field    USING 'VIQMEL-AUSBS'  w_ausbs.
       else.
          PERFORM bdc_field    USING 'VIQMEL-AUSBS'  ' '.
       endif.
    Initially i just tried
      if w_ausbs ne '00000000'.
          PERFORM bdc_field    USING 'VIQMEL-AUSBS'  w_ausbs.
      endif.
    However, the field still gets populated with '00000000' which casues an error since it should be blank.  Able to create manually without entering a value in this field so it is not mandatory.
    Any ideas on how to get this field to be left blank.
    Thanks,
    Jill

    Hi Jill,
    1. U want the date field to be  blank.
    a) make sure it is not compulsory
    b) secondly, make sure, default value
       does not come up when entering
       data in the tcode
    2. If this is so , then
       how is ur w_ausbs defined ?
       a) it should be c(8)
    (so that 0000000 does not come,
      spaces come !)
      and specificlally passit
      using
    PERFORM bdc_field USING 'VIQMEL-AUSBS' w_ausbs. <---
    regards,
    amit m.

Maybe you are looking for

  • SELECT query performance issue

    Hello experts!!! I am facing the performance issue in the below SELECT query. Its taking long time to execute this query. Please suggest how can i improve the performance of this query. SELECT MBLNR MATNR LIFNR MENGE WERKS BUKRS LGORT BWART INTO CORR

  • Understanding the display

    Your SmartBand Talk features an E Ink® display that uses electronic ink technology to reproduce the appearance of ordinary ink on paper. In an E Ink® display, no backlight is used. Instead, ambient light from the environment is reflected from the sur

  • Authorisation variable using customer exit

    Hi, how to populate a authorisation object at runtime? is it possible to have a variable etc that can be populated a runtime? I have a object zsales_off which has different values for different users. i need to create separate roles just to have diff

  • HT201322 How do I "Hide" an app from my purchase history on my iphone 5?

    I've seen instructions on how to do this on so many other devices, but I can't seem to find an answer related to the iPhone 5.

  • Funktion for "Create Table" Statement

    Dear all, I am looking for a function to create a "create table"-SQL statement from an existing SAP Dictionary table. Does anybod y know a abap function to do this. With the SQL Statement I want to create the table in an external Database. Kind Regar