我们经常会遇到对时间进行转换,达到不同的显示效果,默认格式为:2006-6-6 14:33:34,如果要换成200606,06-2006,2006-6-6或更多的格式该怎么办呢?这里将要用到:DateTime.ToString的方法. 一.DateTime.ToString格式模式 下面列出了DateTime.ToString(string format) 中 format 参数.这些模式是区分大小写的:例如,识别“MM”,但不识别“mm”. d 月中的某一天.一位数的日期没
在工作中,如果需要跟XML打交道,难免会遇到需要把一个类型集合转换成XML格式的情况.之前的方法比较笨拙,需要给不同的类型,各自写一个转换的函数.但是后来接触反射后,就知道可以利用反射去读取一个类型的所有成员,也就意味着可以替不同的类型,创建更通用的方法.这个例子是这样做的:利用反射,读取一个类型的所有属性,然后再把属性转换成XML元素的属性或者子元素.下面注释比较完整,就话不多说了,有需要看代码吧! using System; using System.Collections.Generic;
public static string CreateJsonParameters(DataTable dt) { /**/ /**/ /**/ /* /**************************************************************************** * Without goingin to the depth of the functioning of this Method, i will try to give an overview
var timestamp =1539598555000;//时间戳 //时间戳转换成time格式function timestampToTime(timestamp) { var date = new Date(timestamp );//时间戳为10位需*1000,时间戳为13位的话不需乘1000 Y = date.getFullYear() + '-'; M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMont