Example #1
0
        public string getTransformedDate(string value, string inFormat, string outFormat, TimeZoneInfo inZone, TimeZoneInfo outZone)
        {
            string   fieldName  = "date";
            DateTime rangeStart = new DateTime(2000, 1, 1);
            DateTime rangeEnd   = DateTime.Today;

            DateFormatTransformation.FailAction onFailure = DateFormatTransformation.FailAction.DoNothing;
            DateFormatTransformation            t         = DateFormatTransformation.Builder.Start()
                                                            .SetFieldName(fieldName)
                                                            .SetOutputFormat(outFormat)
                                                            .SetInputFormat(inFormat)
                                                            .SetOutputTimeZone(outZone)
                                                            .SetInputTimeZone(inZone)
                                                            .SetRangeStart(rangeStart)
                                                            .SetRangeEnd(rangeEnd)
                                                            .SetOnFailure(onFailure)
                                                            .Build();
            string key = "DOC000001";
            Dictionary <string, string> metadata = new Dictionary <string, string>();

            metadata.Add("date", value);
            Document doc = new Document(key, null, null, metadata, null);

            t.Transform(doc);
            return(doc.Metadata[fieldName]);
        }
 /// <summary>
 /// Initializes a new instance of <see cref="DateFormatEdit"/>.
 /// </summary>
 /// <param name="transformation">The edit initialization settings.</param>
 public DateFormatEdit(DateFormatTransformation transformation)
 {
     this.FieldName      = transformation.FieldName;
     this.OutputFormat   = transformation.OutputFormat;
     this.InputFormat    = transformation.InputFormat;
     this.OutputTimeZone = transformation.OutputTimeZone;
     this.InputTimeZone  = transformation.InputTimeZone;
     this.RangeStart     = transformation.RangeStart;
     this.RangeEnd       = transformation.RangeEnd;
     this.OnFailure      = transformation.OnFailure;
 }