Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Java Java-get-example Java Get Month from Date

Related Tutorials


 
 

Share on Google+Share on Google+

Java Get Month from Date

Advertisement
In the given example, you will see how to retrieve the current month from the current date using Java Application Language.

Java Get Month from Date

     

In the given example, you will see how to retrieve the current month from the current date using Java Application Language. 

You can see in the given example that we have called java.util package that contains number of framework classes and utilities with date and time facilities in Java. That means if you want to show the date in your application then you'll have to call java.util package in the program code.

 

Java code to Get Month from Date

import java.text.*;
import java.util.*;
public class GetMonthFromDate {
public static void main(String args[]) {
  
Date date = new Date();
SimpleDateFormat sdf;

sdf = new SimpleDateFormat("MM");
System.out.println("Month " + sdf.format(date));
}
}

Output will be displayed as:

Download Source Code

Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: October 15, 2008

Related Tutorials

Discuss: Java Get Month from Date   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0
DMCA.com