January 6, 2010

Get year from java.util.Date

import java.text.SimpleDateFormat;
import java.util.Date;

public class Test {
  public static void main(String args[]) throws Exception {
    Date date = new Date();
    SimpleDateFormat simpleDateformat = new SimpleDateFormat("yyyy");
    System.out.println("Year: " + simpleDateformat.format(date));
  }
}

No comments:

Post a Comment