• .net中后端接口时间格式处理


    int useridx = Convert.ToInt32(context.Request.QueryString["useridx"]);
    int type = Convert.ToInt32(context.Request.QueryString["type1"]);

    DataTable dt = BLL.ActivitySystem.Get_ShowDatal20181214(bdate, edate, useridx, type);

    ////时间格式的转化
    Newtonsoft.Json.Converters.IsoDateTimeConverter timeFormat = new Newtonsoft.Json.Converters.IsoDateTimeConverter();
    timeFormat.DateTimeFormat = "MM-dd HH:mm";
    string list = Newtonsoft.Json.JsonConvert.SerializeObject(dt, Newtonsoft.Json.Formatting.Indented, timeFormat);

    ///转换成json

    //string result = JsonConvert.SerializeObject(
    //new
    //{
    // data = new { list = dt },

    //});
    context.Response.Write(list);

    ////接口时间格式处理

    // GET: api/Test/5
    public List<Article> Get(int id)
    {
    List<Article> ls = test.Testshow(id);
    GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings.Converters.Add(
    new Newtonsoft.Json.Converters.IsoDateTimeConverter()
    {
    DateTimeFormat = "yyyy-MM-dd HH:mm:ss"
    }
    );
    return ls;
    }

  • 相关阅读:
    Kubernetes DNS服务配置案例
    Dockerfile常用指令
    Docker常用命令
    Kubernetes常用命令
    阿里云ECS安装Kubernetes问题收集与解答
    712. Minimum ASCII Delete Sum for Two Strings
    845. Longest Mountain in Array
    815. Bus Routes
    204. Count Primes
    190. Reverse Bits
  • 原文地址:https://www.cnblogs.com/yjm8023/p/10309865.html
Copyright © 2020-2023  润新知