#this will parse ok
print Date.Formatter.FormatString
print Date.Formatter.Parse("21Jun2000")
dt = Date.Formatter.Parse("7/28/2014")
#this line will crash
#print Date.Formatter.Parse("28/7/2014")
#change the correct culture
from System.Globalization import CultureInfo
parser = Date.CreateCultureSpecificFormatter(CultureInfo("es-MX"))
#now is safe to parse
print parser.Parse("28/7/2014")
print parser.Parse("27-10-2014")
print parser.Parse("DEC31-2014")
#current date and time
from System import DateTime
now = DateTime.Now
today = DateTime.Today
#format date
dt = Document.Properties["selectedDate"] #01/15/2019
print dt.ToString("MMM yy") #shows Jan 19
No comments:
Post a Comment