get Current Year Start Time - Android java.util

Android examples for java.util:Year

Description

get Current Year Start 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");

    public static Date getCurrentYearStartTime() {
        Calendar c = Calendar.getInstance();
        Date now = null;//from ww w.j  a  va2 s  . co  m
        try {
            c.set(Calendar.MONTH, 0);
            c.set(Calendar.DATE, 1);
            now = shortSdf.parse(shortSdf.format(c.getTime()));
        } catch (Exception e) {
            e.printStackTrace();
        }
        return now;
    }
}

Related Tutorials