Java Calendar Day getDayString(Calendar cal1)

Here you can find the source of getDayString(Calendar cal1)

Description

get Day String

License

Open Source License

Declaration

public static String getDayString(Calendar cal1) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.Calendar;

public class Main {
    public static String getDayString(Calendar cal1) {
        String day = cal1.get(Calendar.YEAR) + "-";

        if (cal1.get(Calendar.MONTH) < 9) {
            day = day + "0" + (cal1.get(Calendar.MONTH) + 1) + "-";
        }/*from w  ww  . java  2s. c  om*/

        if (cal1.get(Calendar.MONTH) >= 9) {
            day = day + (cal1.get(Calendar.MONTH) + 1) + "-";
        }

        if (cal1.get(Calendar.DAY_OF_MONTH) < 10) {
            day = day + "0" + cal1.get(Calendar.DAY_OF_MONTH);
        }

        if (cal1.get(Calendar.DAY_OF_MONTH) >= 10) {
            day = day + cal1.get(Calendar.DAY_OF_MONTH);
        }

        return day;
    }
}

Related

  1. getDayEndCalendar(Calendar cal)
  2. getDayName(Calendar cal)
  3. getDayOfPeriod(Calendar cal, long timems)
  4. getDaysFromThen(Calendar aDate)
  5. getDayStr(Calendar cal)
  6. getDayStringByCalendar(Calendar calendar)
  7. getEndDay(Calendar cal)
  8. getEndOfDay(Calendar c)
  9. getEndOfDay(Date date, Calendar cal)