Java Format - Java SimpleDateFormat .set2DigitYearStart (Date startDate)








Syntax

SimpleDateFormat.set2DigitYearStart(Date startDate) has the following syntax.

public void set2DigitYearStart(Date startDate)

Example

In the following code shows how to use SimpleDateFormat.set2DigitYearStart(Date startDate) method.

//from  w ww .ja v a2  s  .  c o m
import java.text.DateFormat;
import java.text.FieldPosition;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {
  public static void main(String[] argv) throws Exception {

    SimpleDateFormat formatter = new SimpleDateFormat("yy");
    formatter.set2DigitYearStart(new Date());
    
    System.out.println(formatter.format(new Date()));
  }
}

The code above generates the following result.