hour

How to know if now time is between two hours?

北城以北 提交于 2019-12-18 02:17:15
问题 I have a now time: new Date(); And I have some hour constants, for example, 23 and 8 (it's 11pm or 23:00, 8am or 08:00). How I can know is now time between it's two hour constants? It need to run some code of program or not to run if now time is between in two hours, for example, do not run some code if its already evening and while it is not a morning. Here the image to better explain: Some situations when silent mode does not fire: 00:00 20.06.13 - 23:00 20.06.13 // after 23.00 can loud!!

Subtract n hours from a DateTime in Ruby

坚强是说给别人听的谎言 提交于 2019-12-17 23:15:10
问题 I have a Ruby DateTime which gets filled from a form. Additionally I have n hours from the form as well. I'd like to subtract those n hours from the previous DateTime. (To get a time range). DateTime has two methods "-" and "<<" to subtract day and month, but not hour. (API). Any suggestions how I can do that? 回答1: You could do this. adjusted_datetime = (datetime_from_form.to_time - n.hours).to_datetime 回答2: You can just subtract less than one whole day: two_hours_ago = DateTime.now - (2/24.0

sql中两个时间类型相减得到的值

左心房为你撑大大i 提交于 2019-12-13 21:32:30
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 今天有人把数据库两个time类型的字段查出来并做了减法,得到一个长形的数字。这个数字是什么? 首先在数据库里建立一张test表(mysql的数据库) CREATE TABLE `NewTable` ( `id` int(10) NOT NULL AUTO_INCREMENT , `time1` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP , `time2` timestamp NULL DEFAULT NULL , PRIMARY KEY (`id`) ) 然后录入两条数据,用如下语句查询 SELECT time2,time1,time2-time1 FROM `test`; 查询结果如下,结论是这个差值1的单位貌似是秒。 2012-05-15 19:02:17 2012-05-15 19:02:16 1 把time1和time2的类型改成date。这个结果的单位是0. 把time1和time2的类型改成datetime,这个结果如下,貌似单位还是秒。 2012-05-15 19:02:16 2012-05-15 19:02:17 -1.000000 今天遇到的数字结果不确定的情形并没有复现,难道数据库是因为数据库的类型是oracle?

UTC to local hour in MATLAB

我们两清 提交于 2019-12-13 05:38:55
问题 I have this cell array: date_hour = '30/07/2012 00:00' '30/07/2012 01:00' '30/07/2012 02:00' '30/07/2012 03:00' '30/07/2012 04:00' '30/07/2012 05:00' '30/07/2012 06:00' '30/07/2012 07:00' '30/07/2012 08:00' '30/07/2012 09:00' '30/07/2012 10:00' '30/07/2012 11:00' '30/07/2012 12:00' '30/07/2012 13:00' '30/07/2012 14:00' '30/07/2012 15:00' '30/07/2012 16:00' '30/07/2012 17:00' '30/07/2012 18:00' '30/07/2012 19:00' '30/07/2012 20:00' '30/07/2012 22:00' '30/07/2012 21:00' '30/07/2012 23:00' The

Get all full hours of every day of a year

倖福魔咒の 提交于 2019-12-12 07:27:35
问题 I need to get / print on command line every full hour of every day of a given year, e.g. 2011 but I am struggling to code it in Java. Has anybody ever coded this issue? 回答1: This should work: final DateFormat df = DateFormat.getDateTimeInstance(); final Calendar c = Calendar.getInstance(); c.clear(); for (c.set(2011, Calendar.JANUARY, 1, 0, 0, 0); c.get(Calendar.YEAR) == 2011; c.add(Calendar.HOUR_OF_DAY, 1)) System.out.println(df.format(c.getTime())); Notice, for example, this subtlety in the

How to get the MAX(Hour) and The MIN(Hour) for each day in this query?

江枫思渺然 提交于 2019-12-11 02:26:10
问题 I have this structure of table Diary: CREATE TABLE Diary ( [IdDiary] bigint, [IdDay] numeric(18,0) ); INSERT INTO Diary ([IdDiary], [IdDay]) values (51, 1), (52, 2), (53, 5); And this other structure for table DiaryTimetable: CREATE TABLE DiaryTimetable ( [IdDiary] bigint, [Hour] varchar(50) ); INSERT INTO DiaryTimetable ([IdDiary], [Hour]) VALUES (51, '09:00'), (51, '09:30'), (51, '10:00'), (51, '10:30'), (51, '11:00'), (51, '11:30'), (52, '11:00'), (52, '11:30'), (52, '12:00'), (52, '12:30'

Java Calendar Hour of Day Returning 12 Hour Format

孤街浪徒 提交于 2019-12-10 14:18:58
问题 In the Java docs, Calendar.HOUR is supposed to return the hour in the 12 hour format, and Calendar.HOUR_OF_DAY is supposed to return the hour in the 24 hour format, but both of these are returning in the 12 hour format. My Code: Calendar rightNow = Calendar.getInstance(); int hour = rightNow.get(Calendar.HOUR_OF_DAY); System.out.println("hour: " + hour); There is a question that is similar to mine already, but there's is for a specific time and I'm attempting to do this with the current time.

GAE Pricing: Always On feature and instances charging

笑着哭i 提交于 2019-12-08 03:12:14
问题 There's something I really don't get about the new pricing. As far as I can see, I am now billed (amongst others) for the number of "instance/hours". On the other hand, a while back I've opted for the "Always on" feature, which since then effectively has 3 "Resident" instances of my application always running. Now, A.F.A.I.C.S. , on the old pricing model, the one where I was charged by CPU Time used, the "always on" feature was great, not only did it made the app more responsive, but since

Java Swing GUI hour glass

心已入冬 提交于 2019-12-07 09:46:07
问题 There is a JTabbedPane In my Swing program. When user clicks on a tab, the program takes a while to get the data and process the results, then shows the results in the selected tab. How can I display a hour glass, or something of that effect so that user knows it's processing data? Not to click on the tab again before it finishes it job. 回答1: A JProgressBar (possibly in indetermiante mode) sounds right - put that on the tab until the data has been fetched. A well-designed UI shouldn't force

subset data for a day if data between two hours of the day meets criteria?

Deadly 提交于 2019-12-06 16:56:37
I’m fairly new to R and it would be great if you could help out with this problem as i havent been able to find any answers to this problem online. This is part of my data frame (DF) (it goes on until 2008 in this format) Counter Date Hour counts 1245 26/05/2006 0 1 1245 26/05/2006 100 0 1245 26/05/2006 200 2 1245 26/05/2006 300 0 1245 26/05/2006 400 5 1245 26/05/2006 500 3 1245 26/05/2006 600 9 1245 26/05/2006 700 10 1245 26/05/2006 800 15 This is my question: I need to subset my code so that between the hours of 600 and 2200 if there are counts over 0 then I need to keep the whole day (000