import java.util.Date;
import java.util.GregorianCalendar;
class Utils {
public static String dateToString(Date date, boolean leadingZeros) {
String dateStr;
if (date == null) {
dateStr = "";
} else {
GregorianCalendar calendar = new GregorianCalendar();
calendar.setTime(date);
int day = calendar.get(GregorianCalendar.DAY_OF_MONTH);
int month = calendar.get(GregorianCalendar.MONTH) + 1;
dateStr = (leadingZeros && day < 10 ? "0" : "") + day + ". "
+ (leadingZeros && month < 10 ? "0" : "") + month + ". "
+ calendar.get(GregorianCalendar.YEAR) + ".";
}
return dateStr;
}
}