Here you can find the source of getMonthBegin(String strdate)
Parameter | Description |
---|---|
strdate | a parameter |
public static String getMonthBegin(String strdate)
//package com.java2s; //License from project: Open Source License public class Main { public static String getMonthBegin(String strdate) { java.util.Date date = parseDate(strdate); return format(date, "yyyy-MM") + "-01"; }//from w ww .j a va2 s . com public static java.util.Date parseDate(String dateStr, String format) { java.util.Date date = null; try { java.text.DateFormat df = new java.text.SimpleDateFormat(format); date = (java.util.Date) df.parse(dateStr); } catch (Exception e) { e.printStackTrace(); } return date; } public static java.util.Date parseDate(String dateStr) { return parseDate(dateStr, "yyyy-MM-dd"); } public static String format(java.util.Date date, String format) { String result = ""; try { if (date != null) { java.text.DateFormat df = new java.text.SimpleDateFormat(format); result = df.format(date); } } catch (Exception e) { } return result; } }