Here you can find the source of appendDate(StringBuffer buf, Calendar cal)
private static StringBuffer appendDate(StringBuffer buf, Calendar cal)
//package com.java2s; //License from project: Open Source License import java.util.Calendar; public class Main { /**//from ww w . ja va 2s. com * Append date (in YYYY-MM-DD format) to specified buffer. */ private static StringBuffer appendDate(StringBuffer buf, Calendar cal) { buf.append(cal.get(Calendar.YEAR)).append('-'); appendInt2(buf, cal.get(Calendar.MONTH) + 1).append('-'); appendInt2(buf, cal.get(Calendar.DAY_OF_MONTH)); return buf; } /** * Same as {@link #formatInt2(int)} but appends to specified buffer. */ private static StringBuffer appendInt2(StringBuffer buf, int n) { if (n < 10) { buf.append('0'); } buf.append(n); return buf; } }