View Problem

Parse a date and time from a string

Given the string "2008-05-06 13:29", parse it as a date representing 6th March, 2008 1:29:00pm in the local time zone.
ExpandDiskEdit
erlang
% AFAIK, no datetime-parsing library exists; 'parse_to_datetime' is a simplistic, problem-specific hack
LocalDateTime = erlang:universaltime_to_localtime(parse_to_datetime("2008-05-06 13:29:34")),
ExpandDiskEdit
clojure
(.. (SimpleDateFormat. "yyyy-MM-dd HH:mm")
(parse "2008-05-06 13:29"))
ExpandDiskEdit
groovy
def date = new SimpleDateFormat("yyy-MM-dd HH:mm").parse("2008-05-06 13:29")
DiskEdit
groovy
def date = Date.parse("yyy-MM-dd HH:mm", "2008-05-06 13:29")

Submit a new solution for erlang, clojure, or groovy
There are 16 other solutions in additional languages (cpp, csharp, fantom, fsharp ...)