Java Month Day getStringOfFirstDayInMonth()

Here you can find the source of getStringOfFirstDayInMonth()

Description

get String Of First Day In Month

License

Apache License

Declaration

public static String getStringOfFirstDayInMonth() 

Method Source Code

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

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

public class Main {

    public static String getStringOfFirstDayInMonth() {
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
        String temp = sdf.format(date);
        String firstDayInMoth = "";
        firstDayInMoth = temp + "-01";

        return firstDayInMoth;

    }/*  www .ja va 2s.c o m*/

    /**
     * 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. getMonthWeek(String curday)
  2. getMonthWeek(String curday)
  3. getPreviosMonthFirstDay()
  4. getShortFirstDayOfMonth()
  5. getStringOfFirstDayInMonth()
  6. isFirstDayOfMonth()
  7. isLastDayOfMonth()
  8. isLastDayOfMonth(Calendar cal)
  9. lastDayOfLastMonth()