Note that this code may not compile (typo's), but i hope you'll get the idea.
[code] Date sampledate = ... ...; ... Calendar cal = Calendar.getInstance(); cal.setTime(sampleDate); int weekNumInYear = cal.get(Calendar.WEEK_OF_YEAR); int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK); ... etc. etc. [/code] Difference calcs: [code] Calendar cal = Calendar.getInstance(); cal.clear(); cal.set(2009, 5, 19); Date date1 = cal.getTime(); cal.clear(); cal.set(2009, 6, 20); Date date2 = cal.getTime(); int diffInNumberOfHours = ((int)date2.getTime() - (int)date1.getTime ()) / (1000 * 60 * 60); [/code] If you want the number of days between date1 and date2, it becomes tricky. You have to deal with possible daylight saving time changes inbetween date1 and date2: Number of hours in a day can be 23 or 25. That's why you can't always divide diffInNumberOfHours by 24 to get the number of days... but if you want to ignore daylight saving time changes, just divide diffInNumberOfHours by 24 to get the number of days. On May 18, 9:11 pm, daehoon <[email protected]> wrote: > Hi~~ everyone. > 1. > how to get it's week when we know a date, not current date. > if I input 5-22, return Friday. > > 2. > If I input 2 dates, 5-19 & 6-20, how to know how many days between > them --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

