You can use the [DateTime.format(String)][1] method and a [Java SimpleDateFormat][2] as the parameter.

    System.debug(Datetime.now().format('yyyy-MM-dd\'T\'HH:mm:ss.SSSZ'));

gives:

 > 2015-05-12T15:43:36.358-0700

This will be for the current users local time zone. Note: 

> "If the time zone cannot be determined, GMT is used."

If you want more control over the timezone you can use the [DateTime.format(String, String)][3] method and specify the TimeZone.


  [1]: https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_datetime.htm#apex_System_Datetime_format_2
  [2]: http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html
  [3]: https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_datetime.htm#apex_System_Datetime_format_3