WEEK « Date Time « Java Data Type Q&A

1. What is a good, simple way to compute ISO 8601 week number?    stackoverflow.com

Suppose I have a date, i.e. year, month and day, as integers. What's a good (correct), concise and fairly readable algorithm for computing the ISO 8601 week number of the week ...

2. Is it possible to get the previous day of the week using Joda-Time?    stackoverflow.com

I am new to Joda-Time and was looking at getting the previous working/week day. My initial try was done on a Monday and I wanted to get the date for T ...

3. Get week start timestamp and week end timestamp using Java SE API and Joda Time (based on ISO)    stackoverflow.com

How may I get week start timestamp (2010-03-01 00:00:00 UTC) and week end timestamp (2010-03-08 00:00:00 UTC) given a java.util.Date (or Joda DateTime), or year and ISO week number, using Java ...

4. How to get dates of a week (I know week number)?    stackoverflow.com

I know the week number of the year, a week is start from Sunday, then Monday, Tuesday...,Saturday. Since I know the week number, what's the efficient way to get the dates of ...

5. A very simple java code (to get date of a week day), but Very Strange result I get, WHY?    stackoverflow.com

I have the following java code to get the date of a specific week day:

SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
cal.set(Calendar.YEAR, 2010);
cal.set(Calendar.WEEK_OF_YEAR, 37); //week 37 of year 2010
cal.set(Calendar.DAY_OF_WEEK, Calendar.THURSDAY);
When ...

6. How to detect if a date is within this or next week in java?    stackoverflow.com

If I have a date of an event, such as 2011-01-03, how to detect if it is within this or next week in java ? Any sample code ? Edit : I thought ...

7. java get day of week is not accurate    stackoverflow.com

i am trying to determine what day of the week is the first day of the month but for some reason it is not returning me the correct day of the ...

8. find out first day of a particular week in joda time? java    stackoverflow.com

is there a way to get the date of the first day of the week(monday). for instance i want to find out what date was this weeks monday based on todays current ...

9. Modelling multiple days of the week    stackoverflow.com

This is the second time i've come accross a one-many relationship between object and weekday and I'm not sure if i'm modelling it in the best way:

MyObject {

10. How to determine day of week by passing specific date?    stackoverflow.com

For Example I've "23/2/2010" (23th Feb 2010), I want to pass it to a function and the function returns day of week? In this example, the function should return String "Tue". Additionally, ...

11. Point of time in a week    stackoverflow.com

Is there a simple way to store points of time relative to days of a week and not an exact date in Java (e.g. Monday 11:00 pm instead of Monday, ...

12. How do you get the date/time range for “this week” using the Joda date/time library in Java?    stackoverflow.com

Assuming you can calculate the date/time range for "today" by following Jon Skeet's advice:

LocalDate today = now.toLocalDate();
LocalDate tomorrow = today.plusDays(1);

DateTime startOfToday = today.toDateTimeAtStartOfDay(now.getZone());
DateTime startOfTomorrow = tomorrow.toDateTimeAtStartOfDay(now.getZone());

Then check if startOfToday <= ...

13. Joda time : Most recent week and month    stackoverflow.com

What would be the best way to get the start/end dates of most recent complete week and most recent complete month given the date. I.E given the todays date, how to find ...

14. How in Java find dates for previous 2 mondays?    stackoverflow.com

May be like this:

for(int i=0;i<15;i++){
Calendar cal = new GregorianCalendar();
cal.add(Calendar.DAY_OF_MONTH, -1);

if (cal.Calendar.DAY_OF_WEEK==1){
But may be exists more simple way? Thanks.

15. How to find nearest week day for an arbitrary date?    stackoverflow.com

Is there an elegant way to find the nearest day of the week for a given date using JodaTime? I initially thought setCopy() would be it, but this sets the day ...

16. convert string, with day of week to timestamp    stackoverflow.com

Are there any ways to convert "Wed, 30 Nov 2011 09:13:00" to a timestamp besides programatically coding it yourself? Like any libraries/functions that can help accomplish this? thanks

18. How can i get the first and the last date for a specific week    coderanch.com

Rinku, I don't really think you'd want to attempt to rewrite the whole java date/calendar libraries! The easiest thing for you to do would be to use the java.util.Calendar (get an instance by calling the static Calendar.getInstance() method). Calendar has a function Calendar.get(int) which can be used to get the day of week ( mon,tues,...) by using as getInstance(DAY_OF_WEEK). This factors ...

19. return date for a given week number in a month    coderanch.com

Simple. Use a Calendar. Set the YEAR to 2004, MONTH to AUGUST, the DAY_OF_WEEK_IN_MONTH to 2, and the DAY_OF_WEEK to WEDNESDAY. Get the time, done. If this confuses you, you might want to study the differences between WEEK_OF_MONTH and DAY_OF_WEEK_IN_MONTH. - Peter [ August 23, 2004: Message edited by: Peter den Haan ]

20. getting the start date for a week number    coderanch.com

Hi, I am trying to get the start date for a week when given the week number an year. My calender setting will be Calendar gregorianCalendar = new GregorianCalendar(); gregorianCalendar.setFirstDayOfWeek(Calendar.MONDAY); gregorianCalendar.setMinimalDaysInFirstWeek(4); for example: if my method is passed in 40/2005 i.e. week 40 in year 2005 The method should pass back 03/10/2005 i.e. 3rd Oct 2005

21. Getting the day of Monday given the date of other day in that week    coderanch.com

Hi, I have a instance of Calendar which is set to say day = 25 month = 7 year = 2006 Now the day comes to be Friday. I need to extract the date of the immediate previous Monday, which in this case is the 21st. Is there some way to do that combing given functions and constants of the Calendar ...

22. how do i get day of the week from the date    coderanch.com

You can use Calendar API to get the day of the week.Let's say the date is 6th Aug 2002.Set the calendar object as following: cal.set(2002,7,6); where - 2002 is the year 7 - month (Jan is 0 so Aug is 7) 6 - date import java.util.*; class Test{ public static void main(String args[]){ Calendar cal = Calendar.getInstance(); cal.set(2002,7,6); System.out.println("Day is "+cal.get(cal.DAY_OF_WEEK)); ...

23. Get WeekStart Date & End date by Week Number in java    coderanch.com

Seems like an interesting home work assignment. Is the first week of the year the first week that has a date in the year or the first week that starts after the first day? So if Jan 1 is a Tuesday, does the first week start on the Sunday before or the Sunday after? A good place to start would be ...

26. Get current week date    coderanch.com

Hi, I want to source code in java to display a date of current week please give me different different example. i want that One table and in this table starting with Monday and ending with Sunday and display the date of current week.. Ex : Monday Tuesday Wednesday Thursday Friday Saturday Sunday Date Date Date Date Date Date Date above ...

27. Get current week date    coderanch.com

30. to get the timestamp of the last day, week, month    coderanch.com

Hi, I want to perform search results according to dates.For that purpose i want to calculate 1)Timestamp of the last day. 2)Timestamp of First day of the last week. 3)Timestamp of First day of the last month. 4)Timestamp of First day of last three month etc. Please help me out in this; Thanks;

31. To Find out Date by inputting Week    dbforums.com

hi all Here i have a query in java. I have a selection list for week name, say Week1, Week2, Week3 etc.. and a month selection list for a particular month. User will select a month and a week (say Week2) and clicks on submit button. Based on this week, i have to extract Day and Month and pass as parameter ...

32. Calculate the day of the week for a particular date    java-forums.org

I have to write this program to show what day of week you were born i wrote this code but i don't know what i have to do after :( :mad::confused: You will be using the JOptionPane object and the .showInputDialog method to prompt for user input. Prompt the user for a String object that represents a date in the ...

33. Calculating the week from the given date----urgent    forums.oracle.com

Look at the Calendar class, it will have all you need. Hint: get the day of the week and the last day of the month--ie Monday and 30, and then you'll know how many slots are left in the week or until the end of the month--which ever comes first. But isn't it true all weeks have 7 days?

34. how to get the date of Friday for the given week    forums.oracle.com

HI, I have a requirement to get the date of Friday for the given week. Eg: I have an input of 200722 (Yearweek), From this I need to get the Date of the friday for this week 22 of Year 2007. Plz let me know how to get this.. Thanks in advance.. Sridhar.

36. Get week number for any given date    forums.oracle.com

37. Need a Help in finding the start Date and End Date of a week    forums.oracle.com

I need a help, I have a date for eg,05-08-2009 (Wednesday). i need to get the week's start date and week's end date. Week start date in my region is SATURDAY and week end date is FRIDAY . So for my given input it should return start date as 01-08-2009 (Saturday )and end date as 07-08-2009 (Friday ).

39. Calculate date for a week ago    forums.oracle.com

Suppose I could make a couple loops. One to subtract the Calendar.DATE by 1 until its equal to 1. From there, go back a month, and keep going until it has iterated up to 7 times. Use the month and day value to compare. Put the year in there as well. Ill try this for now, but please post suggestions for ...

40. Start Date of Week from Week Number    forums.oracle.com

Hi i need to get the start date of the week based on the week number e.g the start date of week 1 in 2008 would be 01 Jan and start date for week 2 would be 06 Jan and week 3 would be 13 Jan etc Any advice would be great Thanks David

42. How do i get the date when enter a week number    forums.oracle.com

You create a Calendar instance. You then use add, set, and roll methods to change values. Then you get a Date object representing the date you set the calendar to. Then you can use a java.text.SimpleDateFormat to print the date as you like. Read the docs. I think you'll find it's pretty straightforward.

43. day of week from a given date    forums.oracle.com

44. Get the date of a particular week day from given date    forums.oracle.com

I have a given date. from that date i want to get the date of sunday of that week wat is the best possible way to do the same. for eg: if i am given 03/11/2007 which is a saturday i want to get 27/10/2007 which is the sunday which falls in the same week as of 03/11/2007 can anybody please ...

45. get the first and the last date of a week    forums.oracle.com

Hi all I need to get the first and the last date of a specific week. I need a function that returns two date passing it just one date. The function has to calculate the first and the last date of the week of the argument date. hope to be clear regards

46. How can I get the start date and end date of a certain week?    forums.oracle.com

Hello, in my java code, I can get the week ID , using org.joda.time.base.AbstractDateTime.getWeekOfWeekyear() , for example, this week is the 16th week of this year. And I want to get the start date(date of Monday) and end date(date of Sunday) of the week. Is there any method can supply such date value??thanks

47. Week no from a given Date Range    forums.oracle.com