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 === ...
随机推荐
- Spring 3.0: Unable to locate Spring NamespaceHandler for XML schema namespace
被这个问题折磨着很久:参考: http://have23.iteye.com/blog/1340777 (cfx 与 spring 整合的时候出现的问题: org.springframework.be ...
- 李洪强iOS开发之OC语言类的深入和分类
OC语言类的深入和分类 一.分类 (一)分类的基本知识 概念:Category 分类是OC特有的语言,依赖于类. 分类的作用:在不改变原来的类内容的基础上,为类增加一些方法. 添加一个分类: 文件 ...
- lintcode:哈希函数
题目: 哈希函数 在数据结构中,哈希函数是用来将一个字符串(或任何其他类型)转化为小于哈希表大小且大于等于零的整数.一个好的哈希函数可以尽可能少地产生冲突.一种广泛使用的哈希函数算法是使用数值33,假 ...
- .net与linux
Mono是什么? http://blog.sina.com.cn/s/blog_693ffe760100k5uh.html Mono是一个开放源代码,Linux版的Microsfot.NET开发平台 ...
- 关于Linux的时间与时区
转:http://linux.chinaunix.net/techdoc/beginner/2007/06/22/960790.shtml 首先要说明的是我的系统是fedora,其他系统可能不完全相同 ...
- 安装nginx创建错误
./configure: error: the HTTP gzip module requires the zlib library. 解决: yum install -y zlib-devel -- ...
- 海明距离hamming distance
仔细阅读ORB的代码,发现有很多细节不是很明白,其中就有用暴力方式测试Keypoints的距离,用的是HammingLUT,上网查了才知道,hamming距离是相差位数.这样就好理解了. 我理解的Ha ...
- QTP之对测试用例的自动化过程的分解
第一部分:自动化一个测试用例 当你要开始自动化一个测试用例的时候,有一些重要的事情需要完成.当你完成所有这些事情的时候,测试脚本的自动化也随之完成. 在这里,我们将首先在大部分的自动化测试用例里找出所 ...
- netty httpserver
netty也可以作为一个小巧的http服务器使用. package com.ming.netty.http.httpserver; import java.net.InetSocketAddress; ...
- Hibernate--基本映射标签和属性介绍
一.映射文件的基本结构举例: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hiberna ...