- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我想知道有没有办法让我每天在一天中的某个时间显示一个消息框。例如
if (DateTime >= 11:59)
{
messagebox.show("Good Morning");
}
else if (DateTime == 12:00 to 16:59)
{
messagebox.show("Good Afternoon");
}
else if (DateTime <= 17:00)
{
messagebox.show("Good Evening");
}
如果有办法做到这一点,请帮助我。谢谢。
最佳答案
您可以使用 TimeOfDay
property DateTime
与 TimeSpan
值的比较;
var dt = DateTime.Now;
if (dt.TimeOfDay <= new TimeSpan(11, 59, 0))
{
MessageBox.Show("Good Morning");
}
else if (dt.TimeOfDay >= new TimeSpan(12, 0, 0) && dt.TimeOfDay < new TimeSpan(16, 59, 0))
{
MessageBox.Show("Good Afternoon");
}
else if (dt.TimeOfDay >= new TimeSpan(17, 0, 0))
{
MessageBox.Show("Good Evening");
}
关于c# - 在时间段内激活,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31355472/
如果我使用以下方法计算 java.time 中 2 个 LocalDate 之间的差异: Period p = Period.between(testDate, today); 然后我得到一个包含年、
我正在开发一个有多种不同费率的预订平台。这些费率由一天中的时间、星期几和一年中的一天决定。以下是所涉及的间隔类型的一些示例: 周一至周五,上午 9 点至下午 5 点 周六和周日,中午 12 点到早上
我有大量数据,包括开始时间、停止时间和值。开始和停止时间因行而异,以 5 分钟为增量。我正在尝试创建一个新的数据框,该数据框具有 5 分钟的间隔以及该间隔在行的开始和停止范围内的所有行的总和。 我有一
我有一个这样的表: --------------------------------------------- |Id | Step | StartedAt
我有一个网络应用程序,用户将在其中输入 2 个日期。一个 StartDate 和一个 EndDate。现在我想编写它,以便在选择 StartDate 和 EndDate 时确定有多少周,然后显示这些周
这看起来并不直截了当。 我正在尝试: @Override public int compare(Period o1, Period o2) { return o1.toStandardDays
我必须为团队发送 session 邀请,这是我的邮件 $ical = 'BEGIN:VCALENDAR PRODID:-//Microsoft Corporation//Outlook 11.0
我有这个 ISO 8601 时间段字符串: P0Y0M0DT3H5M0.000S 并且 PHP7.4 无法用它构造 DateInterval。 format('%h Hours %m Minutes
我想要获取包含一段时间(格式为 HH:MM:SS)的多个单元格的总和。在 LibreOffice Calc 4.0.3.3 中,我复制粘贴了 G14:G21 范围内的时间段,并将单元格格式设置为时间
我有一个表(MySQL),每n秒捕获一次样本。该表有很多列,但重要的是两列:时间戳(TIMESTAMP 类型)和计数(INT 类型)。 我想做的是获取一定时间范围内计数列的总和和平均值。例如,我每 2
我有一个表(MySQL),每n秒捕获一次样本。该表有很多列,但重要的是两列:时间戳(TIMESTAMP 类型)和计数(INT 类型)。 我想做的是获取一定时间范围内计数列的总和和平均值。例如,我每 2
我在一个项目上使用 joda-time (1.6.2),我正在做的其中一件事就是计算预测时间和实际时间之间的差异。这种差异有时是积极的,有时是消极的。虽然适当的方法可能是使用 Duration 而不是
我有一个表 (MySQL),它每 n 秒捕获一次样本。该表有很多列,但最重要的是两列:一个时间戳(TIMESTAMP 类型)和一个计数(INT 类型)。 我想做的是获取计数列在一段时间内的总和和平均值
我想让我的折线图显示过去 3 个月的数据。 GDS 有一个“最后一个季度”的日期范围,但这显示的是 Q1、Q2、Q3 或 Q4。我需要的是过去3个整月(不算当月)的数据。我尝试创建一个计算字段,但事实
我想让我的折线图显示过去 3 个月的数据。 GDS 有一个“最后一个季度”的日期范围,但这显示的是 Q1、Q2、Q3 或 Q4。我需要的是过去3个整月(不算当月)的数据。我尝试创建一个计算字段,但事实
我是一名优秀的程序员,十分优秀!