define a static method to convert datatime to a formatted string with uesr-defined
2005-09-20 10:46
465 查看
public static string DateToString( DateTime dt , string splitter )
{
string sTemp = String.Empty;
if(dt.Month < 10)
{
sTemp += "0";
}
sTemp += dt.Month.ToString();
sTemp += splitter;
if( dt.Day < 10 )
{
sTemp += "0";
}
sTemp += dt.Day.ToString();
sTemp += splitter;
sTemp += dt.Year.ToString();
return sTemp;
}
{
string sTemp = String.Empty;
if(dt.Month < 10)
{
sTemp += "0";
}
sTemp += dt.Month.ToString();
sTemp += splitter;
if( dt.Day < 10 )
{
sTemp += "0";
}
sTemp += dt.Day.ToString();
sTemp += splitter;
sTemp += dt.Year.ToString();
return sTemp;
}
相关文章推荐
- 【待】1.4 Write a method to replace all spaces in a string with'%20'.
- ASIHTTP请求的数据解析出错问题Error Domain=NSCocoaErrorDomain Code=3840 "Unable to convert data to string around
- 诡异的DataTime.Now.ToString()
- How to get response content with specified post data by post method
- DataTime or ToString用法
- How to convert int to string with C++ - forest的日志 - 网易博客
- 1.failed to find target with hash string 'android - 20' 2. Gradle DSL method not found: 'android()'
- maven依赖设置版本号的坑:java.lang.NoSuchMethodError: No static method stringToValue(Ljava/lang/String;)Ljava/
- How to respond with HTTP 400 error in a Spring MVC @ResponseBody method returning String?
- unable to convert mysql date/time value to system.data.time 11/14
- long[] or int[] convert to string[] method
- Q1.4 Write a method to replace all spaces in a string with ‘%20’.
- ASP.NET how to send data with post method?
- Ch1-5: Write a method to replace all spaces in a string with ‘%20’.
- Go convert string to time
- [D3] Convert Input Data to Output Values with Linear Scales in D3
- Get json formatted string from web by sending HttpWebRequest and then deserialize it to get needed data
- Simple trick to convert Date format with timezone in Java!
- System.DataTime.Now.ToString()的各种格式
- DataTime.ToString("xx") 转换