完善 jackson 解析时间。
This commit is contained in:
parent
5496c06eea
commit
07ae9f88a3
@ -1,23 +1,24 @@
|
|||||||
|
/*
|
||||||
|
* @Author: Kane
|
||||||
|
* @Date: 2022-04-24 10:21:46
|
||||||
|
* @LastEditors: Kane
|
||||||
|
* @LastEditTime: 2022-04-24 11:28:58
|
||||||
|
* @FilePath: \DisasterWarning\src\main\java\com\cpic\xim\notify\disaster\QWeatherDisasterWarning.java
|
||||||
|
* @Description:
|
||||||
|
*
|
||||||
|
* Copyright (c) ${2022} by Kane, All Rights Reserved.
|
||||||
|
*/
|
||||||
package com.cpic.xim.notify.disaster;
|
package com.cpic.xim.notify.disaster;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
public class QWeatherDisasterWarning
|
public class QWeatherDisasterWarning
|
||||||
{
|
{
|
||||||
public QWeatherDisasterWarning( String code,
|
public QWeatherDisasterWarning()
|
||||||
String updateTime,
|
{}
|
||||||
String fxLink,
|
|
||||||
Vector<QWeatherDisasterWarningItem> warning,
|
|
||||||
QWeatherDisasterWarningRefer refer )
|
|
||||||
{
|
|
||||||
this.code = code;
|
|
||||||
this.updateTime = updateTime;
|
|
||||||
this.fxLink = fxLink;
|
|
||||||
this.warning = warning;
|
|
||||||
this.refer = refer;
|
|
||||||
}
|
|
||||||
|
|
||||||
public QWeatherDisasterWarning() {}
|
|
||||||
|
|
||||||
public String getCode()
|
public String getCode()
|
||||||
{
|
{
|
||||||
@ -29,12 +30,12 @@ public class QWeatherDisasterWarning
|
|||||||
this.code = code;
|
this.code = code;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUpdateTime()
|
public Date getUpdateTime()
|
||||||
{
|
{
|
||||||
return updateTime;
|
return updateTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUpdateTime( String updateTime )
|
public void setUpdateTime( Date updateTime )
|
||||||
{
|
{
|
||||||
this.updateTime = updateTime;
|
this.updateTime = updateTime;
|
||||||
}
|
}
|
||||||
@ -69,9 +70,19 @@ public class QWeatherDisasterWarning
|
|||||||
this.refer = refer;
|
this.refer = refer;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String code;
|
@JsonProperty( "code")
|
||||||
private String updateTime;
|
private String code;
|
||||||
private String fxLink;
|
|
||||||
|
@JsonProperty( "updateTime")
|
||||||
|
@JsonFormat( pattern = "yyyy-MM-dd\'T\'HH:mmXXX")
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
|
@JsonProperty( "fxLink")
|
||||||
|
private String fxLink;
|
||||||
|
|
||||||
|
@JsonProperty( "warning")
|
||||||
private Vector<QWeatherDisasterWarningItem> warning;
|
private Vector<QWeatherDisasterWarningItem> warning;
|
||||||
private QWeatherDisasterWarningRefer refer;
|
|
||||||
|
@JsonProperty( "refer")
|
||||||
|
private QWeatherDisasterWarningRefer refer;
|
||||||
}
|
}
|
||||||
|
@ -1,79 +1,61 @@
|
|||||||
package com.cpic.xim.notify.disaster;
|
package com.cpic.xim.notify.disaster;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
//import com.fasterxml.jackson.annotation.JsonIgnore;
|
//import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
|
||||||
public class QWeatherDisasterWarningItem
|
public class QWeatherDisasterWarningItem
|
||||||
{
|
{
|
||||||
public QWeatherDisasterWarningItem() {}
|
public QWeatherDisasterWarningItem()
|
||||||
public QWeatherDisasterWarningItem( String id,
|
{}
|
||||||
String sender,
|
|
||||||
String pubTime,
|
public QWeatherDisasterWarningItem( String id, String sender, Date pubTime, String title,
|
||||||
String title,
|
String status, String level, String type, String typeName, String text, String related,
|
||||||
String status,
|
String urgency, String certainty)
|
||||||
String level,
|
|
||||||
String type,
|
|
||||||
String typeName,
|
|
||||||
String text,
|
|
||||||
String related,
|
|
||||||
String urgency, String certainty )
|
|
||||||
{
|
{
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.sender = sender;
|
this.sender = sender;
|
||||||
this.pubTime = pubTime;
|
this.pubTime = pubTime;
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.status = status;
|
this.status = status;
|
||||||
this.level = level;
|
this.level = level;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.typeName = typeName;
|
this.typeName = typeName;
|
||||||
this.text = text;
|
this.text = text;
|
||||||
this.related = related;
|
this.related = related;
|
||||||
this.urgency = urgency;
|
this.urgency = urgency;
|
||||||
this.certainty = certainty;
|
this.certainty = certainty;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals( Object o )
|
public boolean equals( Object o )
|
||||||
{
|
{
|
||||||
if ( this == o )
|
if ( this == o)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if ( o == null || getClass() != o.getClass() )
|
if ( o == null || getClass() != o.getClass())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
QWeatherDisasterWarningItem that = (QWeatherDisasterWarningItem) o;
|
QWeatherDisasterWarningItem that = (QWeatherDisasterWarningItem) o;
|
||||||
return id.equals( that.id ) && Objects.equals( sender, that.sender ) && Objects.equals( pubTime,
|
return id.equals( that.id ) && Objects.equals( sender, that.sender )
|
||||||
that.pubTime ) && Objects.equals(
|
&& Objects.equals( pubTime, that.pubTime ) && Objects.equals( title, that.title )
|
||||||
title,
|
&& Objects.equals( status, that.status ) && Objects.equals( level, that.level )
|
||||||
that.title ) && Objects.equals( status, that.status ) && Objects.equals( level,
|
&& Objects.equals( type, that.type ) && Objects.equals( typeName, that.typeName )
|
||||||
that.level ) && Objects.equals(
|
&& Objects.equals( text, that.text ) && Objects.equals( related, that.related )
|
||||||
type,
|
&& Objects.equals( urgency, that.urgency )
|
||||||
that.type ) && Objects.equals( typeName, that.typeName ) && Objects.equals( text,
|
&& Objects.equals( certainty, that.certainty );
|
||||||
that.text ) && Objects.equals(
|
|
||||||
related,
|
|
||||||
that.related ) && Objects.equals( urgency, that.urgency ) && Objects.equals( certainty,
|
|
||||||
that.certainty );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode()
|
public int hashCode()
|
||||||
{
|
{
|
||||||
return Objects.hash( id,
|
return Objects.hash( id, sender, pubTime, title, status, level, type, typeName, text,
|
||||||
sender,
|
related, urgency, certainty );
|
||||||
pubTime,
|
|
||||||
title,
|
|
||||||
status,
|
|
||||||
level,
|
|
||||||
type,
|
|
||||||
typeName,
|
|
||||||
text,
|
|
||||||
related,
|
|
||||||
urgency,
|
|
||||||
certainty );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getId()
|
public String getId()
|
||||||
@ -96,12 +78,12 @@ public class QWeatherDisasterWarningItem
|
|||||||
this.sender = sender;
|
this.sender = sender;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPubTime()
|
public Date getPubTime()
|
||||||
{
|
{
|
||||||
return pubTime;
|
return pubTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPubTime( String pubTime )
|
public void setPubTime( Date pubTime )
|
||||||
{
|
{
|
||||||
this.pubTime = pubTime;
|
this.pubTime = pubTime;
|
||||||
}
|
}
|
||||||
@ -198,8 +180,11 @@ public class QWeatherDisasterWarningItem
|
|||||||
|
|
||||||
private String id;
|
private String id;
|
||||||
private String sender;
|
private String sender;
|
||||||
@JsonFormat(pattern="yyyy-MM-dd'T'HH:mm")
|
|
||||||
private String pubTime;
|
@JsonProperty( "pubTime")
|
||||||
|
@JsonFormat( shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd\'T\'HH:mmXXX")
|
||||||
|
private Date pubTime;
|
||||||
|
|
||||||
private String title;
|
private String title;
|
||||||
private String status;
|
private String status;
|
||||||
private String level;
|
private String level;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* @Author: Kane
|
* @Author: Kane
|
||||||
* @Date: 2022-04-22 10:53:49
|
* @Date: 2022-04-22 10:53:49
|
||||||
* @LastEditors: Kane
|
* @LastEditors: Kane
|
||||||
* @LastEditTime: 2022-04-23 23:44:54
|
* @LastEditTime: 2022-04-24 11:31:50
|
||||||
* @FilePath: \DisasterWarning\src\test\java\com\cpic\xim\wechat\officalAccount\sendMessageTest.java
|
* @FilePath: \DisasterWarning\src\test\java\com\cpic\xim\wechat\officalAccount\sendMessageTest.java
|
||||||
* @Description:
|
* @Description:
|
||||||
*
|
*
|
||||||
@ -16,6 +16,7 @@ import org.junit.Test;
|
|||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
import com.cpic.xim.httpUtil.*;
|
import com.cpic.xim.httpUtil.*;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
@ -72,6 +73,9 @@ public class sendMessageTest
|
|||||||
QWeatherDisasterWarning warning =
|
QWeatherDisasterWarning warning =
|
||||||
mapper.readValue( warningJSON, QWeatherDisasterWarning.class );
|
mapper.readValue( warningJSON, QWeatherDisasterWarning.class );
|
||||||
|
|
||||||
|
SimpleDateFormat format = new SimpleDateFormat( "yyyy-MM-dd HH:mm" );
|
||||||
|
String putTime = format.format( warning.getUpdateTime() );
|
||||||
|
|
||||||
sendMessage.sendWeatherDisasterWarning( url, warning );
|
sendMessage.sendWeatherDisasterWarning( url, warning );
|
||||||
}
|
}
|
||||||
catch (Exception error)
|
catch (Exception error)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user