date-manipulation

How do I do date manipulation in SpEL?

亡梦爱人 提交于 2021-01-28 09:31:13
问题 How can I do date manipulation in the Spring Expression language? <si:service-activator id="entryReader" expression="@blogEntryReader.getEntriesBetweenDates(payload.startDate, payload.startDate **PLUS 30 DAYS**)" input-channel="blogEntryReaderChannel"/> 回答1: Unfortunately, the java.util.Calendar doesn't have a builder API so it's not SpEL-friendly. One solution would be to use a helper class... public static class CalendarManip { public static Date addDays(Date date, int days) { Calendar cal

How do I do date manipulation in SpEL?

本秂侑毒 提交于 2021-01-28 09:23:15
问题 How can I do date manipulation in the Spring Expression language? <si:service-activator id="entryReader" expression="@blogEntryReader.getEntriesBetweenDates(payload.startDate, payload.startDate **PLUS 30 DAYS**)" input-channel="blogEntryReaderChannel"/> 回答1: Unfortunately, the java.util.Calendar doesn't have a builder API so it's not SpEL-friendly. One solution would be to use a helper class... public static class CalendarManip { public static Date addDays(Date date, int days) { Calendar cal

Get the next time that respect a time format and not a pervious one

断了今生、忘了曾经 提交于 2020-01-07 03:42:49
问题 I am trying to get the time to the next "6:00:00", I am using moment: let shiftEnd = moment("06:00:00", "HH:mm:ss") console.log(shiftEnd.inspect()) It gets me the previous 6:00:00, the one with the same day as now() . moment("2017-07-31T06:00:00.000") now() is: moment("2017-07-31T12:20:57.076") What's the best way to get the next 6am that's not passed yet? 回答1: You are getting a moment object for the current day because, as moment Default section states: You can create a moment object

SQL Count for a Date Column

雨燕双飞 提交于 2019-12-22 04:38:22
问题 I have a table that containts a set of columns one of it is a Date column. I need to count how many occurrences of the values of that column refer to the same month. And return if for one month, that count sums more than 3. For example: ____________________ | DATE | .... | --------------------- 1998-09-02 1998-09-03 1998-10-03 1998-10-04 This must return no value. Because it doesn't have the necessary number of repetitions. But this it does: ____________________ | DATE | .... | --------------

Start and end date of a current month

别说谁变了你拦得住时间么 提交于 2019-12-17 10:33:39
问题 I need the start date and the end date of the current month in Java. When the JSP page is loaded with the current month it should automatically calculate the start and end date of that month. It should be irrespective of the year and month. That is some month has 31 days or 30 days or 28 days. This should satisfy for a leap year too. Can you help me out with that? For example if I select month May in a list box I need starting date that is 1 and end date that is 31. 回答1: There you go: public

Get average interval between two dates PHP

ⅰ亾dé卋堺 提交于 2019-12-13 03:39:46
问题 So I have the following array ( $lifeSpanArray ) and I'm looking to calculate the average interval between the two dates. What I have so far, but I think I'm thinking slightly wrong with it: <?php foreach ($lifeSpanArray as $key) { $newTimeAdd = new DateTime($key["timeAdded"]); $newTimeRead = new DateTime($key["timeRead"]); $interval = $newTimeAdd->diff($newTimeRead); var_dump($interval); } ?> Which outputs: Array ( [0] => Array ( [timeAdded] => 07/15/2014 [timeRead] => 07/15/2014 ) [1] =>

add days and hours in date/time field and get the updated date/time in php using mysql

ぃ、小莉子 提交于 2019-12-11 04:58:49
问题 I would like to provide the ability for users to submit a datetime value, along with values representing additional days/hours, and then store the datetime that results from adding the two in a mysql database. 回答1: If you want to do it in PHP, this should help: $datetime = '2010-02-11 12:00:00'; $days = '5'; $hours = '3'; $new_datetime = date('Y-m-d H:i:s', strtotime("+$days days $hours hours", strtotime($datetime))); echo $new_datetime; # Will output '2010-02-16 15:00:00' 回答2: to add an

MySQL: How to calculate weeks out from a specific date?

北城余情 提交于 2019-12-10 12:57:51
问题 I need to calculate the weeks out from a date in my MySQL select statement. There is a date column in one of the tables, and I need to calculate how many weeks away the date is. SELECT EventDate, (calculation) AS WeeksOut FROM Events; Example: 6 days away, weeks out = 0 7 days away, weeks out = 1 13 days away, weeks out = 1 14 days away, weeks out = 2 回答1: Use the DATEDIFF function: ROUND(DATEDIFF(end_date, start_date)/7, 0) AS weeksout The problem with WEEKS is that it won't return correct

Using awk, how to convert dates to week and quarter?

对着背影说爱祢 提交于 2019-12-08 13:48:11
问题 Using awk, how to convert dates (yyyy-mm-dd) to week and quarter (first day of week set to monday)? Input: a;2016-04-25;10 b;2016-07-25;20 c;2016-10-25;30 d;2017-02-25;40 Wanted output: a;2016-04-25;10;2016-w17;2016-q2 b;2016-07-25;20;2016-w30;2016-q3 c;2016-10-25;30;2016-w43;2016-q4 d;2017-02-25;40;2017-w8;2017-q1 回答1: awk solution: awk -F';' '{ split($2,d,"-"); w = strftime("%W", mktime(d[1]" "d[2]" "d[3]" 00 00 00")); q = int((d[2]+2)/3); print $0,d[1]"-w"w,d[1]"-q"q}' OFS=';' file The

SQL Count for a Date Column

浪尽此生 提交于 2019-12-05 03:04:30
I have a table that containts a set of columns one of it is a Date column. I need to count how many occurrences of the values of that column refer to the same month. And return if for one month, that count sums more than 3. For example: ____________________ | DATE | .... | --------------------- 1998-09-02 1998-09-03 1998-10-03 1998-10-04 This must return no value. Because it doesn't have the necessary number of repetitions. But this it does: ____________________ | DATE | .... | --------------------- 1998-09-02 1998-09-03 1998-09-12 1998-09-14 1998-10-02 1998-11-21 For the november month. Is