Questions tagged [dayofweek]

Usually a function that returns day of the week when a certain date object is passed.

Get day of day of the week in:

691 questions
3
votes
3 answers

Get week span as pair of zero-based day-of-year (0-364 or 0-365) numbers in Java

I need to get week span: start of week (Mo) | end of week (Sun) in days of year. For example, for 5.9.2019, it should be 241-247 (days starting from 0). However, my method produces 250 | 249 public static Pair getWeekSpan(Timestamp…
Talos
  • 457
  • 4
  • 15
3
votes
2 answers

How do I get the current day of week in C++ using date.h?

I am using C++ 14 and am trying to get the current day of week. After some reading I am using date.h by Howard E. Hinnant. However I am struggling to get a day of the week (encoded as 0 thru 6). Something like this prints out Thu: int main(void) …
rrz0
  • 2,182
  • 5
  • 30
  • 65
3
votes
1 answer

How can I find all week numbers of month that are the # week of month in a year with Java?

I am looking to build up a function that return an array with all week numbers of the previous months in a year that are the same week number of one particular month. I am using as first day of week Monday and I am taking as first week of month week…
lezan
  • 759
  • 6
  • 23
3
votes
1 answer

prometheus filter range vector by day_of_week

I use sub-queries to get hourly aggregated values for the last week for example: The number of http requests per hour over the whole last week, which will return 168 values in a range vector. …
radio
  • 897
  • 2
  • 10
  • 25
3
votes
2 answers

Add some rows from pandas dataframe to next, then remove them

I have a pandas dataframe with a lot of columns, some of which have values on weekends. I'm now trying to remove all weekend rows, but need to add the values I remove to the respective following Monday. Thu: 4 Fri: 5 Sat: 2 Sun: 1 Mon: 4 Tue:…
Oli
  • 317
  • 1
  • 2
  • 9
3
votes
2 answers

Java DayOfWeek convert Day Name (String) to Day Number

I am trying to convert String value of a weekday to a Number. I was looking into Enum DayOfWeek (https://docs.oracle.com/javase/8/docs/api/java/time/DayOfWeek.html), but it does not work the way I expected. Code String n =…
Rence
  • 2,900
  • 2
  • 23
  • 40
3
votes
3 answers

For a given date, detect the nth day-of-week in the month, then determine the same in next 6 months, in Java

For a given date, such as 2018-03-05, how do I detect that it is the first Monday of that month? And after determining that fact, how do I calculate the same nth day-of-week in the month for the following six months? For example, Monday 2018-04-02…
Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154
3
votes
1 answer

java TimeZone and TimeUnit and SimpleDateFormat in Android

https://gist.github.com/anonymous/e14bbbb89dd8636f1237c73dc8878b3f I've encountered a bug in this code that causes the last switch statement (line 298 - 307) to return the default for the current day and case 0 for the next day when my emulators…
Mr.Drew
  • 939
  • 2
  • 9
  • 30
3
votes
3 answers

Can Calendar.GetDayOfWeek() return (DayOfWeek)7?

I'm reviewing some code and found this bit (rewritten): if ((int)CultureInfo.CurrentCulture.Calendar.GetDayOfWeek(someDate) == 7) ... I would think this condition always returns false since DayOfWeek (the return type) ranges from 0 to 6, or could…
Koen
  • 3,626
  • 1
  • 34
  • 55
3
votes
1 answer

Day of the week using Zeller's method & Java

I am having difficulty getting the correct output of my Zeller's method code, which is suppose to output the day of the week for a given date. After int f is declared, I am not sure how to fix the if statement for if a number is less than zero. Here…
sara j
  • 33
  • 1
  • 5
3
votes
2 answers

Getting time range between the first day of current week and current time JDK 8

I can easilly calculate time period between the first day of month and current time: /** * Returns the time range between the first day of month and current time in milliseconds. * * @param zoneId time zone ID. * @return a {@code long} array,…
Ernestas Gruodis
  • 8,567
  • 14
  • 55
  • 117
3
votes
2 answers

How to find n'th previous Sunday with Java date time API or Joda-time?

How do we calculate previous Sunday or previous to previous Sunday or in general lets say how to find out sunday prior to n weeks? The catch is if today is Sunday then it should return today as Sunday and not last week. Looking for Joda-Time or Java…
java brain
  • 63
  • 1
  • 8
3
votes
1 answer

Java 8: Find nth DayOfWeek after specific day of month

In Java 8, what I found is TemporalAdjuster temporal = dayOfWeekInMonth(1,DayOfWeek.MONDAY) gives the temporal for the first Monday of a month, and next(DayOfWeek.MONDAY) gives the next Monday after a specific date. But I want to find nth MONDAY…
Mahbub Rahman
  • 1,295
  • 1
  • 24
  • 44
3
votes
0 answers

What is the use of CultureInfo.InvariantCulture.Calendar.GetDayOfWeek?

I was checking out the week numbering codes and I have encountered with this answer on SO. I did not get the use of CultureInfo.InvariantCulture.Calendar.GetDayOfWeek. Is there any reason for not using DayOfWeek property of DateTime as…
Nuri Tasdemir
  • 9,720
  • 3
  • 42
  • 67
3
votes
2 answers

use day of month and day of week both in cron expression

I explored and found that in quartz cron expressions : sec min hour day_of_month month day_of_week year, we can provide either day_of_month or day_of_week, but not both of them, as it's not implemented yet. I want to run the scheduler after…
gbhati
  • 493
  • 1
  • 8
  • 20