Java SimpleDateFormat get2DigitYearStart() Example

SimpleDateFormat class get2DigitYearStart() method example. This example shows you how to use get2DigitYearStart() method.


Syntax is : public Date get2DigitYearStart()
This method returns the beginning date of the 100-year period 2-digit years are interpreted as being within.

Here is the code.
/**
 * @(#) Get2DigitYearStartSimpleDateFormat.java
 * A class representing use of method get2DigitYearStart() of SimpleDateFormat
class in java.text Package.
 * @Version  14-May-2008
 @author   Rose India Team
 */
import java.util.*;
import java.text.*;

class Get2DigitYearStartSimpleDateFormat {

    public static void main(String[] args) {

        // Create new Date object that will be initialized to the current date.
        Date date = new Date();
        System.out.println("Date  by  Date  class          : "+date.toString());
        SimpleDateFormat sdf;

        // Create new SimpleDateFormat object that returns default pattern.
        sdf = new SimpleDateFormat();
        String dateFormat = sdf.format(date);
        System.out.println("Date by SimpleDateFormat class : " + dateFormat);

        // get2DigitYearStart method call for SimpleDateFormat object.
        Date DigitDate = sdf.get2DigitYearStart();
        System.out.println("Beginning date of the 100-year period : " 
                DigitDate.toString());
    }
}

Output of the program.
 Date  by  Date  class          : Sat Jun 14 13:03:16 GMT+05:30 2008
Date by SimpleDateFormat class : 6/14/08 1:03 PM
Beginning date of the 100-year period : Thu Jun 14 13:03:16 GMT+05:30 1928

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US