Java Calendar Add appendDate(StringBuffer sb, Calendar cal)

Here you can find the source of appendDate(StringBuffer sb, Calendar cal)

Description

append Date

License

Open Source License

Declaration

private static void appendDate(StringBuffer sb, Calendar cal) 

Method Source Code

//package com.java2s;

import java.util.Calendar;

public class Main {
    private static void appendDate(StringBuffer sb, Calendar cal) {
        int l_year = cal.get(Calendar.YEAR);
        // always use at least four digits for the year so very
        // early years, like 2, don't get misinterpreted
        ///*from   w w w . j a  v a  2 s . co  m*/
        int l_yearlen = String.valueOf(l_year).length();
        for (int i = 4; i > l_yearlen; i--) {
            sb.append("0");
        }

        sb.append(l_year);
        sb.append('-');
        int l_month = cal.get(Calendar.MONTH) + 1;
        if (l_month < 10)
            sb.append('0');
        sb.append(l_month);
        sb.append('-');
        int l_day = cal.get(Calendar.DAY_OF_MONTH);
        if (l_day < 10)
            sb.append('0');
        sb.append(l_day);
    }
}

Related

  1. addToUTCMilliSeconds(int calendarTime, int actualValue)
  2. addWeekdays(Calendar cal, int days)
  3. addWorkdays(final Calendar calendar, final int dauer)
  4. appendDate(StringBuffer buf, Calendar cal)
  5. appendDate(StringBuffer dateString, Calendar calendar)
  6. appendEra(StringBuffer sb, Calendar cal)
  7. appendTime(Calendar value, StringBuffer dateString)
  8. appendTimeZone(Calendar calendar, StringBuffer dateString)
  9. cloneAndAdd(Calendar source, int field, int amount)