get Current Year End - Java java.util

Java examples for java.util:Year

Description

get Current Year End

Demo Code


//package com.java2s;

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

public class Main {
    public static void main(String[] argv) throws Exception {
        int year = 2;
        System.out.println(getCurrentYearEnd(year));
    }//  w w  w .  jav  a  2 s. c om

    public static Date getCurrentYearEnd(int year) {
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.YEAR, year);
        calendar.set(Calendar.MONTH, 11);
        calendar.set(Calendar.DAY_OF_MONTH, 31);
        calendar.set(Calendar.HOUR_OF_DAY, 23);
        calendar.set(Calendar.MINUTE, 59);
        calendar.set(Calendar.SECOND, 59);
        return calendar.getTime();
    }
}

Related Tutorials