Here you can find the source of getDayString(Calendar cal1)
public static String getDayString(Calendar cal1)
//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; } }