Sponsered Links
Categories
Sponsered Links

Create a date object using calender class

 

This example shows how to create a date object using calender class.

import java.util.Calendar;

public class Main {
  public static void main(String[] args) {
    int year = 2009;
    int month = 0// January
    int date = 1;

    Calendar cal = Calendar.getInstance();
    cal.clear();

    cal.set(Calendar.YEAR, year);
    cal.set(Calendar.MONTH, month);
    cal.set(Calendar.DATE, date);

    java.util.Date utilDate = cal.getTime();
    System.out.println(utilDate);
  }
}

 
 
Sponsered Links
Latest Updates
 
All Content of this site is for learning only. We do not warrant the correctness of its content. The risk from using it lies entirely with the user. While using this site, you agree to have read and accepted our terms of use and privacy policy.
Copyright © 2009 JSPSERVLETTUTORIAL.INFO All Right Reserved