DateTime.IsLeapYear 方法判断是否是闰年,DaysInMonth判断一个月有几天,Addday取得前一天的日期GetYesterDay
一:DateTime.IsLeapYear 方法判断是否是闰年
二:代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace GetDays
{
public partial class Frm_Main : Form
{
public Frm_Main()
{
InitializeComponent();
}
private void btn_Get_Click(object sender, EventArgs e)
{
if (DateTime.IsLeapYear(int.Parse(//判断是否为闰年,IsLeapYear返回bool指定的年份是否为闰年的指示
DateTime.Now.ToString("yyyy"))))
{
MessageBox.Show("本年有366天","提示!");//显示天数信息
}
else
{
MessageBox.Show("本年有365天", "提示!");//显示天数信息
}
}
}
}
三:DaysInMonth判断一个月有几天,截图
四:代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace DaysInMonth
{
public partial class Frm_Main : Form
{
public Frm_Main()
{
InitializeComponent();
}
private void btn_Get_Click(object sender, EventArgs e)
{
int P_Count = DateTime.DaysInMonth(//获取本月的天数,返回指定年和月中的天数。
DateTime.Now.Year, DateTime.Now.Month);
MessageBox.Show("本月有" +//显示本月的天数
P_Count.ToString() + "天", "提示!");
}
}
}
五:Addday取得前一天的日期GetYesterDay,截图
六:代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace GetYesterDay
{
public partial class Frm_Main : Form
{
public Frm_Main()
{
InitializeComponent();
}
private void btn_GetYesterday_Click(object sender, EventArgs e)
{
MessageBox.Show(//显示前一天日期
"昨天是:" + DateTime.Now.AddDays(-1).
ToString("yyyy年M月d日"), "提示!");
}
}
}
DateTime.IsLeapYear 方法判断是否是闰年,DaysInMonth判断一个月有几天,Addday取得前一天的日期GetYesterDay的更多相关文章
- Python 判断闰年,判断日期是当前年的第几天
http://www.cnblogs.com/vamei/archive/2012/07/19/2600135.html Python小题目 针对快速教程 作业答案 写一个程序,判断2008年是否是闰 ...
- System.DateUtils 2. IsInLeapYear 判断是否是闰年
编译版本:Delphi XE7 function IsInLeapYear(const AValue: TDateTime): Boolean; implementation // 判断是否是闰年 f ...
- 用Java程序判断是否是闰年
我们知道,(1)如果是整百的年份,能被400整除的,是闰年:(2)如果不是整百的年份,能被4整除的,也是闰年.每400年,有97个闰年.鉴于此,程序可以作以下设计: 第一步,判断年份是否被400整除, ...
- js判断是否是闰年
JavaScript判断值是否是闰年: 判断是否闰年公式:(year%4==0 && year%100 !=0) ||(year%400 ==0) var year = prompt( ...
- Python中判断是否为闰年,求输入日期是该年第几天
#coding = utf-8 def getLastDay(): y = int(input("Please input year :")) m = int(input(&quo ...
- C# 判断是否为闰年的条件各是
//try 没增加异常数据处理 Console.WriteLine("根据输入的信息计算当年某个月份的天数,以及当年是否是闰年或平年,\n并判断2月份特殊月份的天数."); Con ...
- 日期,为下拉列表添加日期,优化,目前本人博客上最优的解决方案,之前学习的通过判断得到平年闰年,而这个是让系统自动去判断,无须if判断,代码示例
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"% ...
- python——闰年的判断
写一个程序,判断给定年份是否为闰年. 这样定义闰年的:能被4整除但不能被100整除,或者能被400整除都是闰年. while(1): year = input("请输入一个年份,让我判断一下 ...
- js 获取是否为闰年,以及各月的天数 & isLeapYear
js 获取是否为闰年,以及各月的天数 calendar utils isLeapYear const isLeapYear = (year) => { return (year % 4 === ...
随机推荐
- Project Euler 80:Square root digital expansion 平方根数字展开
Square root digital expansion It is well known that if the square root of a natural number is not an ...
- 欧拉工程第62题:Cubic permutations
题目链接 找出最小的立方数,它的各位数的排列能够形成五个立方数 解决关键点: 这五个数的由相同的数组成的 可以用HashMap,Key是由各位数字形成的key,value记录由这几个数组成的立方数出现 ...
- 去掉eclipse的xml和js验证
一.XML Properties > Validation you have two options: 1- Configure Workspace Settings (disable the ...
- Java学习笔记之:Java流程控制
一.介绍 Java流程控制包括顺序控制.条件控制和循环控制. 顺序控制,就是从头到尾依次执行每条语句操作.条件控制,基于条件选择执行语句,比方说,如果条件成立,则执行操作A,或者如果条件成立,则执行操 ...
- Android:储存方式之SharePreferences
使用SharedPreferences保存数据,其实质是采用了xml文件存放数据, 存储位置:/data/data/<package name>/shared_prefs 写入: publ ...
- C#中用JavaScriptSerializer和Json.Net操作json格式的文件
1.json文件 2.写出对应的类 //折扣 public class Discount { public string Qty { get; set; } public string percent ...
- ubuntu下显卡管理
1 Ubuntu下卸载ATI显卡驱动并还原开源驱动[转] 首先卸载已经安装的ATI显卡驱动:cd /usr/share/ati/sudo ./fglrx-uninstall.sh 接着执行下面的代码: ...
- spring 定时任务的 执行时间设置规则(转)
spring 定时任务的 执行时间设置规则 单纯针对时间的设置规则org.springframework.scheduling.quartz.CronTriggerBean允许你更精确地控制任务的运 ...
- C++:对象指针
对象指针概念:每一个对象在初始化后都会在内存中占有一定的空间.因此,既可以通过对象名访问, 也可以通过一个对象地址来访问一个对象.对象指针就是用于存放对象地址的变量. 声明对象指针的一般语法格式为:类 ...
- JDynamic :支持Json反序列化为Dynamic对象
JDynamic :支持Json反序列化为Dynamic对象 2010年 .NET 4.0 发布前后,从3.5向4.0迁移,那时也有一些异构系统的需求,主要是和PHP打交道,通信使用的HTTP 格 ...