Closed GoogleCodeExporter closed 9 years ago
I have a test case that date was correctly parsed, but I need to change my bean
to use Calendar beside Date.
The yaml string:
!Post &firstBobPost
titulo: About the model layer
criadoEm: 2011-08-10
autor: *bob
conteudo: >
The model has a central position in a Play!
The Bean:
@Entity
public class Post extends AbstractPersistable<Long> {
private String titulo;
private Calendar criadoEm;
@Lob
private String conteudo;
@ManyToOne
private Usuario autor;
@OneToMany(mappedBy="post", cascade=CascadeType.ALL)
private List<Comentario> comentarios = new ArrayList<Comentario>();
....
The Test:
DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
assertNotNull(post.getCriadoEm());assertEquals("2011-08-10",
df.format(post.getCriadoEm().getTime()));
Original comment by trse...@gmail.com
on 9 Sep 2011 at 2:57
SimpleDateFormat is using by default your local time zone. Set the GMT time
zone and the problem should disappear:
DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
df.setTimeZone(java.util.TimeZone.getTimeZone("GMT"));
Original comment by py4fun@gmail.com
on 9 Sep 2011 at 4:46
Very nice. Thanks and excuse-me for openning this issue.
Original comment by trse...@gmail.com
on 9 Sep 2011 at 6:11
You are welcome.
Original comment by py4fun@gmail.com
on 9 Sep 2011 at 10:57
Original issue reported on code.google.com by
trse...@gmail.com
on 9 Sep 2011 at 2:50