Android Open Source - YesNoGame Poll Simple Dto






From Project

Back to project page YesNoGame.

License

The source code is released under:

GNU General Public License

If you think the Android project YesNoGame listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package example.swa.yesnogame.domain.dto;
//from  w w  w .ja v  a2  s . co m
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import android.util.Log;

/**
 * Entity. Simple type. Immtuable type. Clonable. Comparable. Equals on "title"
 * (key).
 * 
 * @author Hendrik.Stilke@siemens.com
 * 
 */
public class PollSimpleDto {

  Long Id;
  String Created;
  boolean IsOpen;
  String Owner;
  String Question;
  String Title;

  private static SimpleDateFormat sdfLong = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
  private static SimpleDateFormat sdfShort = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");

  public PollSimpleDto(Long id, Long created, boolean isOpen, String owner, String question, String title) {
    super();
    this.Id = id;
    // e.g. "2014-09-03T20:40:55.496+00:00";
    this.Created = getCreatedStr(created);
    this.IsOpen = isOpen;
    this.Owner = owner;
    this.Question = question;
    this.Title = title;
  }

  public String getCreated() {
    return this.Created;
  }

  private String getCreatedStr(Long created) {
    Date date = new Date(created * 1000);
    String ret = sdfLong.format(date);
    return ret;
  }

  public Long getCreatedTime() {
    Date ret = null;
    try {
      ret = sdfLong.parse(this.Created);
    } catch (ParseException e) {
      try {
        ret = sdfShort.parse(this.Created);
      } catch (ParseException ex) {
        Log.e("DateTime", ex.toString());
      }
    }
    return ret.getTime() / 1000;
  }

  public Long getId() {
    return this.Id;
  }

  public String getOwner() {
    return this.Owner;
  }

  public String getQuestion() {
    return this.Question;
  }

  public String getTitle() {
    return this.Title;
  }

  public boolean isIsOpen() {
    return this.IsOpen;
  }

  public void setCreated(String created) {
    this.Created = created;
  }

  public void setId(Long id) {
    this.Id = id;
  }

  public void setIsOpen(boolean isOpen) {
    this.IsOpen = isOpen;
  }

  public void setOwner(String owner) {
    this.Owner = owner;
  }

  public void setQuestion(String question) {
    this.Question = question;
  }

  public void setTitle(String title) {
    this.Title = title;
  }

}




Java Source Code List

example.swa.yesnogame.BaseActivity.java
example.swa.yesnogame.InitPollActivity.java
example.swa.yesnogame.MainActivity.java
example.swa.yesnogame.PollResultActivity.java
example.swa.yesnogame.VoteActivity.java
example.swa.yesnogame.domain.Poll.java
example.swa.yesnogame.domain.User.java
example.swa.yesnogame.domain.Vote.java
example.swa.yesnogame.domain.dto.PollSimpleDto.java
example.swa.yesnogame.domain.dto.UserSimpleDto.java
example.swa.yesnogame.domain.dto.VoteSimpleDto.java
example.swa.yesnogame.domain.simple.BaseObject.java
example.swa.yesnogame.domain.simple.PollSimple.java
example.swa.yesnogame.domain.simple.UserSimple.java
example.swa.yesnogame.domain.simple.VoteSimple.java
example.swa.yesnogame.domain.util.PollComparator.java
example.swa.yesnogame.domain.util.VoteComparator.java
example.swa.yesnogame.service.IPollService.java
example.swa.yesnogame.service.PollServiceBase.java
example.swa.yesnogame.service.PollServiceCloud.java
example.swa.yesnogame.service.PollServiceMock.java
example.swa.yesnogame.service.PollServiceProvider.java
example.swa.yesnogame.service.PollService.java
example.swa.yesnogame.service.util.EntityFormatEnum.java
example.swa.yesnogame.service.util.RequestMethodEnum.java
example.swa.yesnogame.service.util.RequestUrlParams.java
example.swa.yesnogame.service.util.RequestUrlTask.java
example.swa.yesnogame.ui.YesNoArrayAdapter.java