They met in spring / summer 2009 when they were filming Rum Diaries. It isn't exactly clear when they started dating. Both put out statements in June 2012 saying they were no longer with their respective partners. In this trial Amber testified to incidents in January 2012 I believe so I am not sure of the exact timeline.
Amber was born April 1986 so she would have been 23 when they filmed together, about 26 when they started dating, and 29 when they married, and 30 when they divorced.