700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > java获取下周一整周的日期_当前日期得到本周的开始和结束日期

java获取下周一整周的日期_当前日期得到本周的开始和结束日期

时间:2021-11-07 21:24:53

相关推荐

java获取下周一整周的日期_当前日期得到本周的开始和结束日期

///

/// 本周起止时间

///

///

///

private string weekrange(System.DateTime dt)

{

int weeknow = Convert.ToInt32(dt.DayOfWeek);

int daydiff = (-1) * weeknow;

int dayadd = 6-weeknow;

string datebegin = System.DateTime.Now.AddDays(daydiff).ToString("yyyyMMdd");

string dateend = System.DateTime.Now.AddDays(dayadd).ToString("yyyyMMdd");

return datebegin + " - " +dateend;

}

///

/// 返回指定URL的源代码

///

///

private string GetHTML( string url,string tag)

{

byte[] buf = new byte[38192];

.WebRequest request = WebRequest.Create(url);;

WebResponse response =request.GetResponse();

Stream resStream = response.GetResponseStream();

int count = resStream.Read(buf, 0, buf.Length);

string result = Encoding.Default.GetString(buf, 0, count);

resStream.Close();

Regex reg=new Regex(@"(?.*?"+tag+">)",RegexOptions.IgnoreCase);

string output=reg.Match(result).Value;

return StripHTML(output);

}

///

/// 去除HTML标记

///

/// 包括HTML的源码

/// 已经去除后的文字

public static string StripHTML(string strHtml)

{

string [] aryReg ={

@"",

@"",

@"([/r/n])[/s]+",

@"&(quot|#34);",

@"&(amp|#38);",

@"&(lt|#60);",

@"&(gt|#62);",

@"&(nbsp|#160);",

@"&(iexcl|#161);",

@"&(cent|#162);",

@"&(pound|#163);",

@"&(copy|#169);",

@"(/d+);",

@"-->",

@"

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。