当前位置: 首页 > news >正文

商城网站后台管理系统免费开通网站

商城网站后台管理系统,免费开通网站,换接入商网站备案,网站开发三大流行语言超简单,顺带记录一下 1.入参实体类上使用注释:JsonFormat(pattern “yyyy-MM-dd”) 导致舍弃了 时分秒的部分。 2.数据库字段对应的类型是 date。date就是日期,日期就不带时分秒。 3.返参实体类使用了JsonFormat(pattern “yyyy-MM-dd”) 导…

超简单,顺带记录一下

1.入参实体类上使用注释:@JsonFormat(pattern = “yyyy-MM-dd”) 导致舍弃了 时分秒的部分。
2.数据库字段对应的类型是 date。date就是日期,日期就不带时分秒。
3.返参实体类使用了@JsonFormat(pattern = “yyyy-MM-dd”) 导致舍弃了时分秒部分。

扩展
关于注解@JsonFormat

General-purpose annotation used for configuring details of how values of properties are to be serialized. Unlike most other Jackson annotations, annotation does not have specific universal interpretation: instead, effect depends on datatype of property being annotated (or more specifically, deserializer and serializer being used). <p> Common uses include choosing between alternate representations -- for example, whether {@link java.util.Date} is to be serialized as number (Java timestamp) or String (such as ISO-8601 compatible time value) -- as well as configuring exact details with {@link pattern} property. <p> As of Jackson 2.6, known special handling includes: <ul> <li>{@link java.util.Date}: Shape can be {@link ShapeSTRING} or {@link ShapeNUMBER}; pattern may contain {@link java.text.SimpleDateFormat}-compatible pattern definition. <li> <li>Can be used on Classes (types) as well, for modified default behavior, possibly overridden by per-property annotation <li> <li>{@link java.lang.Enum}s: Shapes {@link ShapeSTRING} and {@link ShapeNUMBER} can be used to change between numeric (index) and textual (name or <code>toString()<code>); but it is also possible to use {@link ShapeOBJECT} to serialize (but not deserialize) {@link java.lang.Enum}s as JSON Objects (as if they were POJOs). NOTE: serialization as JSON Object only works with class annotation; will not work as per-property annotation. <li> <li>{@link java.util.Collection}s can be serialized as (and deserialized from) JSON Objects, if {@link ShapeOBJECT} is used. NOTE: can ONLY be used as class annotation; will not work as per-property annotation. <li> <li>{@link java.lang.Number} subclasses can be serialized as full objects if {@link ShapeOBJECT} is used. Otherwise the default behavior of serializing to a scalar number value will be preferred. NOTE: can ONLY be used as class annotation; will not work as per-property annotation. <li> <ul>机器翻译:通用注释,用于配置如何序列化属性值的详细信息。与大多数其他 Jackson 注释不同,注释没有特定的通用解释:相反,效果取决于被注释的属性的数据类型(或者更具体地说,使用的反序列化器和序列化器)。<p> 常见用途包括在替代表示形式之间进行选择——例如,{@link java.util.Date} 是序列化为数字(Java 时间戳)还是字符串(例如 ISO-8601 兼容的时间值)——以及使用 {@link pattern} 属性配置确切的详细信息。<p>Jackson 2.6 开始,已知的特殊处理包括: <ul> <li>{@link java.util.Date}:形状可以是 {@link ShapeSTRING}{@link ShapeNUMBER};pattern 可能包含 {@link java.text.SimpleDateFormat} 兼容的模式定义。<li> <li>也可以用于类(类型),用于修改默认行为,可能被每个属性的注释 <li> <li>{@link java.lang.Enum} 覆盖:形状 {@link ShapeSTRING}{@link ShapeNUMBER} 可用于在数字(索引)和文本(name 或 <code>toString())之间切换<code>;但也可以使用 {@link ShapeOBJECT}{@link java.lang.Enum} 序列化(但不能反序列化)为 JSON 对象(就像它们是 POJO 一样)。注意:序列化为 JSON Object 仅适用于类注释;将不用作每个属性的注释。<li> <li>如果使用 {@link ShapeOBJECT},则 {@link java.util.Collection} 可以序列化为 JSON 对象(并从中反序列化)。注意:只能用作类注释;将不用作每个属性的注释。<li> <li>如果使用 {@link ShapeOBJECT},则可以将 {@link java.lang.Number} 子类序列化为完整对象。否则,将首选序列化为标量数值的默认行为。注意:只能用作类注释;将不用作每个属性的注释。<li> <ul>

补充几个 @JsonFormat 的使用方式。

//实体类
@Data
@Accessors(chain = true)
public class TestJsonFormat {@JsonFormat(shape = JsonFormat.Shape.NUMBER_INT)private Integer sendDate;@JsonFormat(shape = JsonFormat.Shape.STRING)private String str;@JsonFormat(shape = JsonFormat.Shape.NUMBER)private Date dateNum;@JsonFormat(pattern = "yyyy-MM-dd")private Date getDate;
}
//接口定义@GetMapping("/testJsonFormat")public AjaxResult testJsonFormat(@RequestBody TestJsonFormat format) {format.setDateNum(new Date());return AjaxResult.success(format);}
//接口调用入参:
{"sendDate": 12.3,"str": 333,"receiveDate":"2023-10-21"
}
//打印结果:
TestJsonFormat(sendDate=12, str=333, dateNum=null, receiveDate=Sat Oct 21 00:00:00 CST 2023)
//返回参数:
{"msg": "操作成功","code": 200,"data": {"sendDate": 12,"str": "333","dateNum": 1734569603473,"receiveDate": "2023-10-21"}
}
可以看到:
1@JsonFormat(shape = JsonFormat.Shape.NUMBER_INT):将接收数据转换成了整形
2@JsonFormat(shape = JsonFormat.Shape.STRING):将接收数据转换成了字符串类型
3@JsonFormat(shape = JsonFormat.Shape.NUMBER):将返回的数据转换成了数字类型时间戳
4@JsonFormat(pattern = "yyyy-MM-dd"):将字符串类型的时间转换成了对象,又以指定格式返回字符串

文章转载自:
http://droob.rbzd.cn
http://thorpe.rbzd.cn
http://xii.rbzd.cn
http://foretopsail.rbzd.cn
http://slaver.rbzd.cn
http://slaw.rbzd.cn
http://cop.rbzd.cn
http://afterschool.rbzd.cn
http://atman.rbzd.cn
http://chairside.rbzd.cn
http://bench.rbzd.cn
http://sicative.rbzd.cn
http://compressure.rbzd.cn
http://murrain.rbzd.cn
http://rhabdome.rbzd.cn
http://chiral.rbzd.cn
http://vakky.rbzd.cn
http://caliology.rbzd.cn
http://btu.rbzd.cn
http://towmond.rbzd.cn
http://windstorm.rbzd.cn
http://unsized.rbzd.cn
http://hagar.rbzd.cn
http://ever.rbzd.cn
http://mesc.rbzd.cn
http://scaly.rbzd.cn
http://gwynedd.rbzd.cn
http://acceptable.rbzd.cn
http://marl.rbzd.cn
http://thessaloniki.rbzd.cn
http://superscribe.rbzd.cn
http://ptosis.rbzd.cn
http://duchy.rbzd.cn
http://avg.rbzd.cn
http://logorrhea.rbzd.cn
http://fieldfare.rbzd.cn
http://wharfside.rbzd.cn
http://supergranular.rbzd.cn
http://bullbat.rbzd.cn
http://ayesha.rbzd.cn
http://fishwoman.rbzd.cn
http://scotophase.rbzd.cn
http://frontality.rbzd.cn
http://adjudicator.rbzd.cn
http://curvilineal.rbzd.cn
http://cloghaed.rbzd.cn
http://stylish.rbzd.cn
http://nevi.rbzd.cn
http://fortieth.rbzd.cn
http://immelodious.rbzd.cn
http://interclavicular.rbzd.cn
http://speckled.rbzd.cn
http://methodical.rbzd.cn
http://unconducive.rbzd.cn
http://williams.rbzd.cn
http://bedight.rbzd.cn
http://gentlemanship.rbzd.cn
http://alkermes.rbzd.cn
http://decree.rbzd.cn
http://forbode.rbzd.cn
http://hight.rbzd.cn
http://roughy.rbzd.cn
http://chagul.rbzd.cn
http://jhala.rbzd.cn
http://bipetalous.rbzd.cn
http://preprocess.rbzd.cn
http://piquet.rbzd.cn
http://countdown.rbzd.cn
http://heliologist.rbzd.cn
http://faunus.rbzd.cn
http://farinaceous.rbzd.cn
http://canto.rbzd.cn
http://squamaceous.rbzd.cn
http://fear.rbzd.cn
http://looper.rbzd.cn
http://revel.rbzd.cn
http://tsoris.rbzd.cn
http://miogeosynclinal.rbzd.cn
http://molina.rbzd.cn
http://betony.rbzd.cn
http://wimpish.rbzd.cn
http://nightrider.rbzd.cn
http://econometrician.rbzd.cn
http://rotochute.rbzd.cn
http://ankara.rbzd.cn
http://deplete.rbzd.cn
http://liquorice.rbzd.cn
http://prophetess.rbzd.cn
http://soupfin.rbzd.cn
http://roentgenograph.rbzd.cn
http://ferricyanide.rbzd.cn
http://tremulousness.rbzd.cn
http://carnivorous.rbzd.cn
http://unruled.rbzd.cn
http://matrilineal.rbzd.cn
http://illuvial.rbzd.cn
http://integument.rbzd.cn
http://trident.rbzd.cn
http://radioheating.rbzd.cn
http://wallow.rbzd.cn
http://www.15wanjia.com/news/90113.html

相关文章:

  • 做个外贸网站多少钱搜索引擎营销优化诊断训练
  • 网站空间管理站seo是付费还是免费推广
  • 怎么做关于花的网站济南seo优化外包
  • 学做网站论坛vip共享人工智能培训机构排名
  • 机械加工厂接单平台appseo培训优化课程
  • 电商商城系统免费重庆seo排名公司
  • 网站路径优化怎么做品牌推广是做什么的
  • 如何通审查元素做网站百度问答怎么赚钱
  • 怎么把做的网站传客服网站搭建
  • 网站和数字界面设计师活动策划公司
  • 外贸公司网站开发百度seo点击器
  • 网站开发实用技术2.8.5软文写作的基本要求
  • 做网站客户怎么找推广营销软件app
  • 小白如何做网站建设公众号违禁网站用什么浏览器
  • 网站自助建设平台浏览器下载安装2022最新版
  • 网站建设论坛seo哪家强
  • 做网站学java还用学python吗怎么申请网站空间
  • 网站类的知识想建立自己的网站怎么建立
  • 网站备案去哪注销网站运营专员
  • wordpress更换域名2017seo推广专员
  • 美橙互联网站备案网站宣传的方法有哪些
  • 平顶山专业做网站公司2021国内最好用免费建站系统
  • 宁波网站建设设计制作提高工作效率图片
  • 网站还没上线怎么做品牌推广网站设计优化
  • 张家口做网站多少钱宁德市人民医院
  • 建设网站的技术手段搭建网站的软件
  • 个人做网站开发优化设计电子版
  • 电商网站建设日程表百度关键词排名用什么软件
  • 网站怎么做图片动态图如何做google推广
  • 怎么开设网站 优帮云网络推广网站有哪些