0

Hi, I'm just learning to program and I'm stuck on a basic problem, printing today's date in a form typified by (e.g.) 28 February 2011

import java.util.*; 

	class Date 
	{
 	   	int day, month, year;
	}

	class PrintToday 
	{
		static Date thisDay() 
		{
			Date today = new Date();
			GregorianCalendar c = new GregorianCalendar();	
			today.day = c.get(Calendar.DATE);
			today.month  = c.get(Calendar.MONTH)+1;
			today.year  = c.get(Calendar.YEAR);
			return today;
		}

	
		static String monthName(int m) 
		{
			if (m==1) return "January";
			else if (m==2) return "February";
			else if (m==3) return "March";
			else if (m==4) return "April";
			else if (m==5) return "May";
			else if (m==6) return "June";
			else if (m==7) return "July";
			else if (m==8) return "August";
			else if (m==9) return "September";
			else if (m==10) return "October";
			else if (m==11) return "November";
			else return "December";
		}
		
    		public static void main(String[] args) 
		{		
		       .......
		}
	}

I'm not sure how to implement these classes/methods in the main method.

Edited by Ezzaral: Added code tags. Please use them to format any code that you post.

4
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by mKorbel
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.