Merge changes from branch
This commit is contained in:
@@ -8,6 +8,10 @@ import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlTransient;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
import org.apache.commons.lang3.builder.EqualsBuilder;
|
||||
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
|
||||
@XmlRootElement(name = "book")
|
||||
@XmlType(propOrder = { "id", "name", "date" })
|
||||
public class Book {
|
||||
@@ -53,6 +57,17 @@ public class Book {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Book [id=" + id + ", name=" + name + ", author=" + author + ", date=" + date + "]";
|
||||
return ToStringBuilder.reflectionToString(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return EqualsBuilder.reflectionEquals(this, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return HashCodeBuilder.reflectionHashCode(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBException;
|
||||
@@ -16,7 +17,8 @@ public class Main {
|
||||
book.setId(1L);
|
||||
book.setName("Book1");
|
||||
book.setAuthor("Author1");
|
||||
book.setDate(new Date());
|
||||
TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
|
||||
book.setDate(new Date(1481909329718L));
|
||||
|
||||
JAXBContext context = JAXBContext.newInstance(Book.class);
|
||||
Marshaller marshaller = context.createMarshaller();
|
||||
|
||||
Reference in New Issue
Block a user