Results 1 to 7 of 7

Thread: deprecated getMonth() {RESOLVED}

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2002
    Posts
    72

    Red face deprecated getMonth() {RESOLVED}

    it's been a long time i didn't log in here, this forum changes a lot

    I have a very simple problem, I'm sort of "outdated", need help here.

    Code:
    import java.util.*;
    
    public class MemberManagement{
         :
         :
        // How do I return the month since getMonth() can't be used anymore and I don't understand the API, can someone correct this method for me? Besides "import java.util.*;", anything thing else needed? A full code for this part would be helpful :)
        public int getMonth(){
    	Date a=new Date();
    	return a.getMonth();
        }
    
        :
        :
    }
    Last edited by blur; Jul 3rd, 2003 at 04:07 AM.

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Check the documentation here

    The new way is to use Calendar...
    Code:
    Calendar.get(Calendar.MONTH)
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Oct 2002
    Posts
    72
    but how? I've tried it actually but it doesn't recognise Calender, always give me "cannot resolve symbol".
    The problem is that I don't understand what's the documentation talking about.
    Mind to implement it in my code for me to see?

  4. #4
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Okay, I forgot that Calendar is an abstract class...
    Code:
    public int getMonth()
    {
        return (Calendar.getInstance()).get(Calendar.MONTH);
    }
    should do the trick.
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Oct 2002
    Posts
    72
    Gee.. thanks. No need to import anything right? I haven't try it out yet but it seems very promising hopefully it works, i've spent 3 hours on it last night ;p

  6. #6
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Originally posted by blur
    No need to import anything right?
    Well, yes and no. Calendar is in the java.util package. If you want to import the package, its...
    Code:
    import java.util.*;
    If not, you have to fully qualify the util package...
    Code:
    public int getMonth()
    {
        return (java.util.Calendar.getInstance()).get(java.util.Calendar.MONTH);
    }
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Oct 2002
    Posts
    72
    ok

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width