Results 1 to 3 of 3

Thread: How to get the current month from the OS?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2000
    Location
    Carolina, Puerto Rico, USA
    Posts
    227
    Can someone please tell me how to get the current month, just the month, from the OS ?

    Thanks in advance!!!
    NievesJ

  2. #2
    Guest

    java.util.Calendar

    Since this was returning 0, I believe this returns the Month as an int between 0-11.

    import java.util.*;
    public class Month{
    public static void main(String [] args){
    Calendar c = Calendar.getInstance();
    System.out.println(c.get(Calendar.MONTH));
    }
    }

    I tried
    c.set(Calendar.MONTH, 35);
    before the println to confirm that the range is between 0 and 11. It looks like there are some funky things that you can do with this.

    Depending on your version, you might use
    java.util.Date

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Nov 2000
    Location
    Carolina, Puerto Rico, USA
    Posts
    227
    Thaks a lot that works great!!
    NievesJ

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