Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
Custom Date Format
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using System.Text; namespace Rextester { public class Program { static string except_msj = ""; public static string[] formatoFecha(string cad) { // Arreglo de dos posiciones, almacena la fecha formateada y el mensaje de error string[] array = new string[2] {"", ""}; string caducidad = "01/"; try { string[] celda = cad.Split(' '); switch (celda[0]) { case "enero": caducidad += "01/"; break; case "febrero": caducidad += "02/"; break; case "marzo": caducidad += "03/"; break; case "abril": caducidad += "04/"; break; case "mayo": caducidad += "05/"; break; case "junio": caducidad += "06/"; break; case "julio": caducidad += "07/"; break; case "agosto": caducidad += "08/"; break; case "septiembre": caducidad += "09/"; break; case "octubre": caducidad += "10/"; break; case "noviembre": caducidad += "11/"; break; case "diciembre": caducidad += "12/"; break; } caducidad += celda[1]; array[0] = caducidad; } catch (Exception ex) { except_msj = "Fecha inválida " + ex.Message; array[1] = except_msj; } // 01/07/2019 return array; } public static void Main(string[] args) { string[] Caducidad = new string[2]; for (int i = 0; i < 5; i++) { Caducidad = formatoFecha("julio 2019"); Console.WriteLine(Caducidad[0]); Console.WriteLine(Caducidad[1]); Caducidad = null; } } } }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
x=msgbox("Your Message Here", Button+Icon, "Your Title Here")
unsorted array which has a number in the majority (a number appears more than 50% in the array
eden
Ventmatika testas
print star
Fórum ➡ Calculate the Sum of Values in List of KeyValuePair<> objects ♦
DateTime.Now.Date
Fff
enum flag comparison
Date Conversion
stackse - search stackoverflow differently
Please log in to post a comment.