week « Calendar « Java Data Type Q&A

1. Convert minutes into a week to time using Java's Date and Calendar classes    stackoverflow.com


This is the scenario: I'm given a value which represents a portion of the total number of minutes that exist in a standard week (assuming 10,080 minutes a week and 1,440 ...

2. Java Calendar.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY), will it roll backwards, forwards or unknown?    stackoverflow.com

Suppose the following code is executed on the 22nd of August 2009 (a Saturday)

   Calendar c = Calendar.getInstance();
   c.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
c.get(Calendar.DAY_OF_MONTH) will return 23. I'm interested in ...

3. Joda Time: First day of week?    stackoverflow.com

How do you get the first day of week given a Locale using Joda Time? Point: Most countries use the international standard Monday as first day of week (!). A bunch others ...

4. Calendar.getActualMaximum(Calendar.WEEK_OF_YEAR) weirdness    stackoverflow.com

Either I don't understand the method getActualMaximum(int) or the field WEEK_OF_YEAR, or there's a Sun bug involved (or all three)...could someone explain to me why (at least in a German locale...) ...

5. How to get first day of a given week number in Java    stackoverflow.com

Let me explain myself. By knowing the week number and the year of a date:

Date curr = new Date();
Calendar cal = Calendar.getInstance();
int nweek = cal.WEEK_OF_YEAR;
int year = cal.YEAR;
But now I don't ...

6. Joda time week calculation reasoning    stackoverflow.com

The code below demonstrates the problematic joda-time implementation of week calculation. This behavior is not a bug but a design decision Joda-Time uses the ISO standard Monday to Sunday week. ...

7. Java: getting current Day of the Week value    stackoverflow.com

At the moment, I'm creating a java schedule app and I was wondering how to find the current day of the week while using the Calendar class to get the first ...

8. Java - How to calculate the first and last day of each week    stackoverflow.com

I'm trying to create a weekly calendar that looks like this: http://dhtmlx.com/docs/products/dhtmlxScheduler/sample_basic.html How can I calculate every week date? For example, this week is:

Monday - Sunday

9. How to get Last Week of Month from Calendar in JAVA    stackoverflow.com

How to get Last Week of Month from Calendar in JAVA

10. Java : Get any day in a week from Calendar    stackoverflow.com

Using Calendar I can get the week, year and all details for the current day. How can I navigate to a particualr day in that week? Say, calendar.get(Calendar.DAY_OF_WEEK); returns 3, which means ...

11. How to get the right week of year number through a Calendar?    stackoverflow.com

guys,i am confused by invoking the following method:Calendar.getInstance().get(Calendar.WEEK_OF_YEAR),the result got from that method is not right.Here is my Code:

    Calendar calendar = Calendar.getInstance();

12. Why dec 31 2010 returns 1 as week of year?    stackoverflow.com

For instance:

Calendar c = Calendar.getInstance();
DateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
c.setTime( sdf.parse("31/12/2010"));
out.println( c.get( Calendar.WEEK_OF_YEAR ) );  
Prints 1 Same happens with Joda time. :)

13. java calender weekend of current week    stackoverflow.com

Java using calender i want to get date of current weekend, any quick idea

14. Better way to check if a joda.time.Interval spans exactly 1 calendar week (accounting for daylight savings etc)    stackoverflow.com

Is there a better way of doing this?

boolean oneCalendarWeek = interval.getStart().plusWeeks(1).equals( interval.getEnd() );
I guess the following won't work because of the way equals is implemented...
boolean oneCalendarWeek = interval.toPeriod().equals( Weeks.ONE );

15. How can I calculate the day of week for a date in Java?    stackoverflow.com

How can I write a method in Java, that will tell me the day of the week when I type in the date in the format computeDayOfWeek(Month, Date)?

16. What is the difference between Calendar.WEEK_OF_MONTH and Calendar.DAY_OF_WEEK_IN_MONTH in Java's Calendar class?    stackoverflow.com

Java's Calendar class provides for two fields: WEEK_OF_MONTH and DAY_OF_WEEK_IN_MONTH. Can someone explain the difference to me? It seems that they both return the same value when tested using the ...

17. If I have a specific date of a day, how do I get the date of that day in the previous week?    stackoverflow.com

For example, if I have a "Date" variable "date1" with a value of (dd/mm/yyy) 03/07/2011, which is a Sunday. How do I get the "Date" of the previous Sunday "date2"? which ...

18. Java Calendar using Calendar.DAY_OF_WEEK to get the first and the last dates for a particular date    stackoverflow.com

In my application there lies a code which works abruptly sometimes, its about getting a week interval using the java calendar object through Calendar.DAY_OF_WEEK. The code checked for monday as start of ...

19. Java Calendar - Date is unpredictable after setting day_of_week    stackoverflow.com

I have the following code in a JUnit test, which seemed to work last week is failing this week:

Calendar cal = Calendar.getInstance();
cal.set(2011, Calendar.JULY, 12);
cal.set(Calendar.DAY_OF_WEEK, Calendar.FRIDAY); // push the date to 15
As ...

20. Getting the start and the end date of a week using java calendar class    stackoverflow.com

I want to get the last and the first week of a week for a given date. e.g if the date is 12th October 2011 then I need the dates 10th ...

21. Java Calendar: calculate start date and end date of the previous week    stackoverflow.com

What is most convenient and shortest way to get start and end dates of the previous week? Example: today is 2011-10-12 (input data),but I want to get 2011-10-03 (Monday's date of ...

22. Java: How do I get the date of x day in a month ( e.g. Third Monday in February 2012)    stackoverflow.com

I am somewhat struggling with this. I want to setup my Calendar to let's say: Third Monday in February 2012. And I didn't find any way of doing this using Java. For example, if ...

23. Calendar (WEEK_OF_MONTH) ????    coderanch.com

Hi folks, i have a strange doubt about the classes of the type Calendar. Before, i'd like to know if exists a method witch returns me the days in a week, of a month, in a year, something like getDaysOfWeekOfMonthInYear(int week, int month, int year) ? I did not find anything about, so i decided to implement: Calendar cal = Calendar.getInstance(); ...

24. Calendar 1st day of week changes?    coderanch.com

Anyone want to guess why the first day of the week is changing on me? import java.text.*; import java.util.*; public class TestMe{ public static final boolean DEBUG = false; public static void main(String[] args ){ TestMe test = null; try{ test = new TestMe(); // 2005 Date seed3 = test.toDate( "03/27/2005", "MM/dd/yyyy" ); test.calendarTest( seed3 ); Date seed4 = test.toDate( "03/28/2005", ...

25. Doubt : Calendar.WEEK_OF_YEAR    coderanch.com

Well this week can be regarded as week 1. I wrote a Visual Basic program just yesterday for my work, and it turned out that it sees this week as week 53 and next week as week 2 - week 1 is completely missing. I've writte a similar program as yours to test it: Calendar calendar = Calendar.getInstance(); System.out.println(Calendar.MONDAY); System.out.println(calendar.getFirstDayOfWeek()); System.out.println(calendar.getMinimalDaysInFirstWeek()); ...

26. Calendar to get week number of current month    forums.oracle.com

Hi All, Description: Currently I am working on an application which require to calculate some data for current month from a database where I have the data of all the previous and current month of that year, I can take week number as criteria. Help Required: I can find week of month or year using Calendar methods but how to find ...

27. Problem with Calendar and first day of week    forums.oracle.com

So basically I need first day of first week in a given month in given year. That is bit of code I am using to do that: Calendar Tcal= new GregorianCalendar(year, month, 1); int weekDay=Tcal.getFirstDayOfWeek(); For some reason no matter what year and month values are, weekDay is always beeing set up to 2 (wednesday). Any idea why?

28. about get(Calendar.DAY_OF_WEEK)    forums.oracle.com

first of all Sunday does not return a '0' but a '1'. Sorry about the typo. secondly, I just wanted to be sure that get(Calendar.DAY_OF_WEEK) is absolute and does not depend on the localization. This is not mentioned in the reference, so I guess the answer is 'yes'. I thought maybe it was implied somewhere else I might have accidentally missed. ...

29. calendar with week numbers of a current month    forums.oracle.com

30. Calendar: get first and last day of the week    forums.oracle.com

31. Setting the DAY_OF_WEEK in a calendar.    forums.oracle.com

I have a question about using the java.util.Calendar object. If I want to set the DAY_OF_WEEK to Calendar.TUESDAY, does the WEEK_OF_MONTH always stay the same? In other words, does it ever increment or decrement to a different week? Or does it always remain in the same week and simply changes the date to reflect the Tuesday of the current week? For ...

32. Calendar.DAY_OF_WEEK    forums.oracle.com

I know that I can just use Calendar.MONDAY, but my question was whether Sunday is always 1 and Monday is always 2 etc. For the time being, yes, but should they ever decide to change it (which I doubt, but it wouldn't surprise me if they did) code that uses the constants won't be broken. The whole point of the constants ...

33. Return Calendar based on given Calendar object and Week Name    forums.oracle.com

Hi All, I have to return a Calendar based on a given Calendar date and a String which is a Week Name. For example if the Calendar object is 06/12/2007 and the Week Name is say Friday, I have to return the date as 6/15/2007. If the Calendar object is 06/12/2007 and the week name is say Tuesday, it has to ...

34. Wrong week day when using Calendar    forums.oracle.com

35. Problems with Calendar.get(Calendar.DAY_OF_WEEK)    forums.oracle.com

It's not necessary to set what the first day of week is, it's just to try if it makes any difference (and i forgot not to paste it here :P) I didn't see the constructor has the option to set the date in it, thanks (that will make my code simple and cleaner than now) Let me try it.

36. Calendar week    forums.oracle.com

38. current Calendar week    forums.oracle.com

39. inconsistant results for Calendar.DAY_OF_WEEK?    forums.oracle.com

dude .. ofcouse i did read that... however, no where it's clear that you have to pass an int to get method and get the day index... if it clearly says that Calendar.DAY_OF_WEEK should give you day of the week. should be simple as that..but truely does not give you the day of the week....rather gives you number of days in ...

40. Calendar bug with DAY_OF_WEEK in certain scenarios    forums.oracle.com

Actually I don't see a problem here. You told Calendar to set it's date to November, then to the first week in November, and then you said it should be a Tuesday. My guess is that going back 1 day was Calendar's solution to stay compatible with all your settings: Tuesday of the first week in November (is the last day ...