Android Date Trim convertToShortYear(Date date)

Here you can find the source of convertToShortYear(Date date)

Description

convert To Short Year

Declaration

public static Date convertToShortYear(Date date) 

Method Source Code

//package com.java2s;

import java.util.Calendar;
import java.util.Date;

public class Main {
    public static Date convertToShortYear(Date date) {
        if (date == null) {
            return null;
        }//from w  ww. j  av  a  2 s  .co  m

        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        calendar.set(Calendar.MONTH, Calendar.JANUARY);
        calendar.set(Calendar.DAY_OF_MONTH, 1);
        calendar.set(Calendar.HOUR_OF_DAY, 0);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);

        return calendar.getTime();
    }
}

Related

  1. convertToShortDate(Date date)
  2. convertToShortHour(Date date)
  3. convertToShortMonth(Date date)
  4. convertToShortWeek(Date date)