Line | |
---|
1 | using System;
|
---|
2 | using HeuristicLab.Persistence.Core;
|
---|
3 | using HeuristicLab.Persistence.Interfaces;
|
---|
4 |
|
---|
5 | namespace HeuristicLab.Persistence.Default.Xml.Primitive {
|
---|
6 |
|
---|
7 | public class DateTime2XmlSerializer : PrimitiveXmlSerializerBase<DateTime> {
|
---|
8 |
|
---|
9 | public override XmlString Format(DateTime dt) {
|
---|
10 | return new XmlString(dt.Ticks.ToString());
|
---|
11 | }
|
---|
12 |
|
---|
13 | public override DateTime Parse(XmlString x) {
|
---|
14 | try {
|
---|
15 | return new DateTime(long.Parse(x.Data));
|
---|
16 | } catch (Exception e) {
|
---|
17 | throw new PersistenceException("Exception caugth while trying to reconstruct DateTime object.", e);
|
---|
18 | }
|
---|
19 | }
|
---|
20 |
|
---|
21 | }
|
---|
22 |
|
---|
23 |
|
---|
24 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.