get First Day Of Year - Android java.util

Android examples for java.util:Day

Description

get First Day Of Year

Demo Code


//package com.java2s;

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

import java.util.Locale;

public class Main {

    public static String getFirstDayOfYear() {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd",
                Locale.CHINA);/*from  w  w  w .  j ava2  s  . c om*/
        Calendar cal = Calendar.getInstance();

        cal.set(Calendar.MONTH, Calendar.JANUARY);
        cal.set(Calendar.DAY_OF_MONTH, 1);
        return format.format(cal.getTime());
    }
}

Related Tutorials