Java Month Day getMonthLastDay()

Here you can find the source of getMonthLastDay()

Description

get Month Last Day

License

Open Source License

Declaration

public static String getMonthLastDay() 

Method Source Code

//package com.java2s;
/**/*www  .  j  a v a  2s  .  c  o  m*/
 *  Copyright (c) 2011, Eryptogram.java TAIHEIOT and/or its affiliates. All rights reserved.
 *
 *  Licensed under the TAIHEIOT License, Version 1.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

import java.text.SimpleDateFormat;
import java.util.Calendar;

public class Main {

    public static String getMonthLastDay() {
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
        return formatDateY_M_D(calendar.getTime());
    }

    public static String formatDateY_M_D(java.util.Date date) {
        SimpleDateFormat dateFomater;
        String result = "";
        if (date != null) {
            try {
                dateFomater = new SimpleDateFormat("yyyy-MM-dd");
                result = dateFomater.format(date);
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
        return result;
    }

    public static String getTime(java.util.Date date) {
        return formatDateHMS(date);
    }

    public static String formatDateHMS(java.util.Date date) {
        String result = "";
        if (date != null) {
            try {
                SimpleDateFormat dateFormater = new SimpleDateFormat("HH:mm:ss");
                result = dateFormater.format(date);
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
        return result;
    }
}

Related

  1. getMonthFirstDay(String date)
  2. getMonthFirstDay(T date)
  3. getMonthFristWeekSunday(String month)
  4. getMonthLastDay()
  5. getMonthLastDay()
  6. getMonthLastDay(String curmonth, int month)
  7. getMonthLastDay(String dateString)
  8. getMonthLastDay(String fmt)
  9. getMonthMaxDay(String sDate)