I have 1 problem regarding Date Picker in Android.
I have 2 date pickers:
-
For start date
-
For end date.
In start date I want to set 1st date of current month. And in end date I want to set current date (i.e. today’s date). I have set it and even I get Transaction like that dates… starting from 1st date to the current date. And even I can see in console date as 1st as start date and 25 (i.e. today’s date) as the end date.
But In Date Picker I can see current date only in both. As start date and end date. That means I get output from 1st date to current date but in Date Picker I can see current date only in both Date Picker.
Please help me.
Thanks in Advance.
Code is:
Date sDate=new Date(dp_startdate.getYear()-1900,dp_startdate.getMonth(),1);
Date eDate=new Date(dp_enddate.getYear()-1900,dp_enddate.getMonth(),dp_enddate.getDayOfMonth());
System.out.println("Sdate:"+sDate.toString());
System.out.println("EDate:"+eDate.toString());
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
String startDate=formatter.format(sDate);
String endDate=formatter.format(eDate);
System.out.println("start Date is:"+startDate);
System.out.println("end Date is:"+endDate);
Bundle bundle=new Bundle();
bundle.putString("startDate", startDate);
bundle.putString("endDate", endDate);
System.out.println("start Date is:"+startDate);
System.out.println("start Date is:"+endDate);
Please help me.
Try this–>
EDIT: Pasted xml as well
Like u said u want one datepicker to be fixed to the current month’s first date,So instead of getting value of day from system’s calender(which will give u the current one, you can explicitly put whatever int value there.
Then u can use this value i.e i have used the custom date value in toast..