Here you can find the source of getStartDateOfMonth(String yyyymm)
public static Date getStartDateOfMonth(String yyyymm)
//package com.java2s; /**//from ww w . j a v a 2 s .c om * Copyright (c) 2008 OpenSprout Team. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * */ import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static Date getStartDateOfMonth(String yyyymm) { SimpleDateFormat sformat = new SimpleDateFormat("yyyy-MM-dd"); try { return sformat.parse(yyyymm + "-01"); } catch (Exception e) { throw new RuntimeException(e); } } public static Date getStartDateOfMonth(Date date) { return getStartDateOfMonth(makeYYYYMMWithHypon(date)); } public static String makeYYYYMMWithHypon(Date date) { DateFormat format = new SimpleDateFormat("yyyy-MM"); return format.format(date); } }