How to create UK dates from strings in Pharo Smalltalk?

I have code that successfully parses strings to create dates:

date := string asDate 

But this assumes the US date format is mm / dd / yyyy.

I know that I can output the date as a string in British format as follows:

 date printFormat: #(1 2 3 $/ 1 1) 

So my question is: how do I create a date from a date string in dd / mm / yyyy format in UK format?

I checked the String → asDate method and it has no format parameter. Looking at the Date -> readFrom: class (which calls asDate), it looks like there is UK code there, but how to dictate that this is what I want?

+6
source share
1 answer

Will this work for you?

 Date readFrom: '04/02/2013' readStream pattern: 'dd/mm/yyyy' 
+7
source

All Articles