|
|
Calculating dates
/csbook/solutions/18/A01.cs
using System;
using System.Text;
public class Test {
static void Main(string[] arg) {
foreach (string s in arg) {
Console.Write(s);
if (s.Length == 10 && s[2] == '/' && s[5] == '/') {
StringBuilder buf = new StringBuilder();
buf.Append(s.Substring(3, 2));
buf.Append('.');
buf.Append(s.Substring(0, 2));
buf.Append('.');
buf.Append(s.Substring(6, 4));
Console.WriteLine(": " + buf.ToString());
} else Console.WriteLine(": invalid format");
}
}
}
|
|