<TextView
android:id="@+id/tvDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="dd-MM-yyyy"
android:fontFamily="@font/qb"
android:textColor="@color/white"
android:textSize="@dimen/_12ssp" />
GregorianCalendar startCal = new GregorianCalendar();
Date c = Calendar.getInstance().getTime();
SimpleDateFormat date1 = new SimpleDateFormat("dd", Locale.getDefault());
SimpleDateFormat month1 = new SimpleDateFormat("MM", Locale.getDefault());
SimpleDateFormat year1 = new SimpleDateFormat("yyyy", Locale.getDefault());
binding.tvDate.setText(date1.format(c)+"-"+month1.format(c)+"-"+year1.format(c));
// binding.tvMonth.setText(Rohit.getMonthName(Integer.parseInt(month1.format(c))));
// binding.tvMonth.setText(String.valueOf(month1.format(c)));
// binding.tvYear.setText(year1.format(c));
binding.llDate.setOnClickListener(view -> {
DatePickerDialog dpd = new DatePickerDialog(context,
(view12, year, monthOfYear, dayOfMonth) -> {
// Display Selected date in textbox
startCal.set(Calendar.YEAR, year);
startCal.set(Calendar.MONTH, monthOfYear);
startCal.set(Calendar.DAY_OF_MONTH, dayOfMonth);
int month = monthOfYear + 1;
/* binding.edStartDate.setText((dayOfMonth < 10 ? "0" + dayOfMonth : dayOfMonth) + "-"
+ (month < 10 ? "0" + month : month) + "-" + year);*/
binding.tvDate.setText(String.valueOf(dayOfMonth < 10 ? "0" + dayOfMonth : dayOfMonth)+"-"+String.valueOf(month)+"-"+String.valueOf(year));
setArray();
// binding.tvDate.setText(String.valueOf(dayOfMonth < 10 ? "0" + dayOfMonth : dayOfMonth));
// binding.tvMonth.setText(String.valueOf(Rohit.getMonthName(month)));
// binding.tvYear.setText(String.valueOf(year));
}, startCal.get(Calendar.YEAR), startCal.get(Calendar.MONTH), startCal.get(Calendar.DAY_OF_MONTH));
dpd.show();
});
0 Comments
Post a Comment