Java Month Get getStartDateOfMonth(String yyyymm)

Here you can find the source of getStartDateOfMonth(String yyyymm)

Description

get Start Date Of Month

License

Open Source License

Declaration

public static Date getStartDateOfMonth(String yyyymm) 

Method Source Code

//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);
    }
}

Related

  1. getNearbyMonth(String month, int i)
  2. getReportMonthString()
  3. getSelectMonth(String month)
  4. getShortMonthForInt(final Locale locale, int theMonth)
  5. getSpecficMonthStart(Date date, int amount)
  6. getStrOfNextMonth(String dateStr)
  7. getStrThisMonth()
  8. getThisMonth()
  9. getThisMonth()