first Date Of Month - Android java.util

Android examples for java.util:Month

Description

first Date Of Month

Demo Code


//package com.java2s;

import java.text.ParseException;
import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    public static Date firstDateOfMonth(Date date) {
        try {/*from w ww . j  a v a 2  s. co m*/
            return (new SimpleDateFormat("yyyyMMdd"))
                    .parse((new SimpleDateFormat("yyyyMM")).format(date)
                            + "01");
        } catch (ParseException e) {
            return null;
        }
    }
}

Related Tutorials