[android-developers] Problem Getting the first and last day of current week.
Hi All,
I am using Calendar objects in my application and based on
the current date i am retrieving first and last date of current week.
In emulator o/p is coming as week starting from Sunday to Saturday
correct and in some device the o/p is showing as Monday to Sunday. I
used same code in java. there also o/p is showing from Sunday to
Saturday only. i need the output as Sunday to Saturday only. I used
these code..
Calendar cal = Calendar.getInstance();
int weekOfYear = cal.get(Calendar.WEEK_OF_YEAR);
cal.set(Calendar.WEEK_OF_YEAR, weekOfYear);
SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");
Calendar first = (Calendar) cal.clone();
first.add(Calendar.DAY_OF_WEEK, first.getFirstDayOfWeek() -
first.get(Calendar.DAY_OF_WEEK));
Calendar last = (Calendar) first.clone();
last.add(Calendar.DAY_OF_YEAR, 6);
String fromDate = formatter.format(first.getTime());
String toDate = formatter.format(last.getTime());
If anybody knows the reason means then plz tell me the solution. if
these method is wrong means then plz send the code....
Thanks for All,
S.Seshu
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home