Java SQL Date getFirstDayOfThisMonth()

Here you can find the source of getFirstDayOfThisMonth()

Description

get First Day Of This Month

License

Apache License

Declaration

public static String getFirstDayOfThisMonth() 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.text.SimpleDateFormat;
import java.util.*;

public class Main {
    static SimpleDateFormat sdfShort = new SimpleDateFormat("yyyyMMdd");

    public static String getFirstDayOfThisMonth() {
        try {/*from w  ww.j  a va 2 s.c  om*/
            return getNowShortDate().substring(0, 6) + "01";
        } catch (Exception e) {
            return "";
        }
    }

    public static String getNowShortDate() throws Exception {
        String nowDate = "";
        try {
            java.sql.Date date = null;
            date = new java.sql.Date(new Date().getTime());
            nowDate = sdfShort.format(date);
            return nowDate;
        } catch (Exception e) {
            throw e;
        }
    }

    /**
     * Returns a string the represents the passed-in date parsed according to
     * the passed-in format. Returns an empty string if the date or the format
     * is null.
     **/
    public static String format(Date aDate, SimpleDateFormat aFormat) {
        if (aDate == null || aFormat == null) {
            return "";
        }
        synchronized (aFormat) {
            return aFormat.format(aDate);
        }
    }
}

Related

  1. getDayOfPerMonth(String theDataStr)
  2. getDiffDays(String begin_dt, String end_dt)
  3. getEndWeekDayOfMonth(String year, String month)
  4. getFileName()
  5. getFirstDayOfNextMonth()
  6. getInsertarEmpleado()
  7. getInsertarEntrada()
  8. getIntervalDays(String sd, String ed)
  9. getLastDay()