get Current Year End Time - Android java.util

Android examples for java.util:Year

Description

get Current Year End Time

Demo Code


//package com.java2s;

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

public class Main {

    private final static SimpleDateFormat shortSdf = new SimpleDateFormat(
            "yyyy-MM-dd");
    private final static SimpleDateFormat longSdf = new SimpleDateFormat(
            "yyyy-MM-dd HH:mm:ss");

    public static Date getCurrentYearEndTime() {
        Calendar c = Calendar.getInstance();
        Date now = null;/*from ww w . j  ava 2s .c o m*/
        try {
            c.set(Calendar.MONTH, 11);
            c.set(Calendar.DATE, 31);
            now = longSdf.parse(shortSdf.format(c.getTime()) + " 23:59:59");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return now;
    }
}

Related Tutorials