Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-06-2007, 11:45 AM
Member
 
Join Date: Dec 2007
Posts: 3
vasu18 is on a distinguished road
Java Calendar Class
Hi..all..

I am new to java,

I want to display previous six months from the current month,i am using th following code
Calendar cal = Calendar.getInstance();

String[] monName = {"January", "February","March", "April", "May", "June", "July",
"August", "September", "October", "November","December"};

String mon1 = monName[cal.get(Calendar.MONTH)];
String mon2 = monName[(cal.get(Calendar.MONTH)-1)];
String mon3 = monName[(cal.get(Calendar.MONTH)-2)];
String mon4 = monName[(cal.get(Calendar.MONTH)-3)];
String mon5 = monName[(cal.get(Calendar.MONTH)-4)];
String mon6 = monName[(cal.get(Calendar.MONTH)-5)];
String mon7 = monName[(cal.get(Calendar.MONTH)-6)];


System.out.println(mon1);
System.out.println(mon2);
System.out.println(mon3);
System.out.println(mon4);
System.out.println(mon5);
System.out.println(mon6);
System.out.println(mon7);

it is working fine in my local machine..
But in the production server,i am not getting the current month as november

i dont know..why..it happens..
can any one..help me
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to use Calendar class JavaBean Java Tips 1 06-26-2008 04:09 PM
How to use Calendar class Java Tip java.util 0 04-04-2008 03:33 PM
java Date and Calendar valoyivd New To Java 1 03-30-2008 07:49 PM
Java Calendar Class vasu18 New To Java 1 12-22-2007 03:51 AM
Error: Cannot access protected member long getTimeInMillis() in class Calendar cachi Advanced Java 1 08-07-2007 08:53 AM


All times are GMT +3. The time now is 05:25 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org