Example usage for com.google.gson GsonBuilder setDateFormat

List of usage examples for com.google.gson GsonBuilder setDateFormat

Introduction

In this page you can find the example usage for com.google.gson GsonBuilder setDateFormat.

Prototype

public GsonBuilder setDateFormat(int style) 

Source Link

Document

Configures Gson to to serialize Date objects according to the style value provided.

Usage

From source file:net.daw.service.specific.implementation.ClienteServiceSpImpl.java

License:Open Source License

@Override
public String getPage(int intRegsPerPag, int intPage, ArrayList<FilterBeanHelper> alFilter,
        HashMap<String, String> hmOrder) throws Exception {
    String data = null;//ww  w. j ava  2 s.co m
    try {
        oConnection.setAutoCommit(false);
        ClienteDaoSpcImpl oClienteDAO = new ClienteDaoSpcImpl(strObjectName, oConnection);
        List<ClienteBeanGenSpImpl> oClientes = oClienteDAO.getPage(intRegsPerPag, intPage, alFilter, hmOrder);
        GsonBuilder gsonBuilder = new GsonBuilder();
        gsonBuilder.setDateFormat("dd/MM/yyyy");
        Gson gson = gsonBuilder.create();
        data = gson.toJson(oClientes);
        data = "{\"list\":" + data + "}";
        oConnection.commit();
    } catch (Exception ex) {
        oConnection.rollback();
        ExceptionBooster.boost(new Exception(this.getClass().getName() + ":getPage ERROR: " + ex.getMessage()));
    }
    return data;
}

From source file:net.daw.service.specific.implementation.ComentarioServiceSpImpl.java

License:Open Source License

@Override
public String get(Integer id) throws Exception {
    String data = null;//from w  w w.ja v a 2  s .c o m
    try {
        oConnection.setAutoCommit(false);
        ComentarioDaoSpcImpl oComentarioDAO = new ComentarioDaoSpcImpl(strObjectName, strObjectName,
                oConnection);
        ComentarioBeanGenSpImpl oComentario = new ComentarioBeanGenSpImpl(id);
        oComentario = oComentarioDAO.get(oComentario, 1);
        GsonBuilder gsonBuilder = new GsonBuilder();
        gsonBuilder.setDateFormat("dd/MM/yyyy");
        Gson gson = gsonBuilder.create();
        data = gson.toJson(oComentario);
        oConnection.commit();
    } catch (Exception ex) {
        oConnection.rollback();
        ExceptionBooster.boost(new Exception(this.getClass().getName() + ":get ERROR: " + ex.getMessage()));
    }
    return data;
}

From source file:net.daw.service.specific.implementation.ComentarioServiceSpImpl.java

License:Open Source License

@Override
public String getPage(int intRegsPerPag, int intPage, ArrayList<FilterBeanHelper> alFilter,
        HashMap<String, String> hmOrder) throws Exception {
    String data = null;/*from   w w w. ja va  2 s  .  c  o m*/
    try {
        oConnection.setAutoCommit(false);
        ComentarioDaoSpcImpl oComentarioDAO = new ComentarioDaoSpcImpl(strObjectName, strObjectName,
                oConnection);
        List<ComentarioBeanGenSpImpl> oComentarios = oComentarioDAO.getPage(intRegsPerPag, intPage, alFilter,
                hmOrder);
        GsonBuilder gsonBuilder = new GsonBuilder();
        gsonBuilder.setDateFormat("dd/MM/yyyy");
        Gson gson = gsonBuilder.create();
        data = gson.toJson(oComentarios);
        data = "{\"list\":" + data + "}";
        oConnection.commit();
    } catch (Exception ex) {
        oConnection.rollback();
        ExceptionBooster.boost(new Exception(this.getClass().getName() + ":getPage ERROR: " + ex.getMessage()));
    }
    return data;
}

From source file:net.daw.service.specific.implementation.CuestionarioService.java

License:MIT License

public String get() throws Exception {

    Connection oConnection = new BoneConnectionPoolImpl().newConnection();
    CuestionarioDao oCuestionarioDao = new CuestionarioDao(oConnection);

    int id = ParameterCook.prepareId(oRequest);

    DocumentoBean oDocumentoBean = new DocumentoBean();
    oDocumentoBean.setId(id);//from ww  w. j a v a2 s . c om
    ArrayList<CuestionarioBean> alCuestionarioBean = new ArrayList();
    alCuestionarioBean = oCuestionarioDao.getCuestionario(oDocumentoBean);

    GsonBuilder gsonBuilder = new GsonBuilder();
    gsonBuilder.setDateFormat("dd/MM/yyyy");
    Gson gson = gsonBuilder.create();
    String data = "{\"status\":200,\"message\":" + gson.toJson(alCuestionarioBean) + "}";

    return data;

}

From source file:net.daw.service.specific.implementation.CuestionarioService.java

License:MIT License

public String getall() throws Exception {

    Connection oConnection = new BoneConnectionPoolImpl().newConnection();
    CuestionarioDao oCuestionarioDao = new CuestionarioDao(oConnection);
    ArrayList<CuestionarioBean> alCuestionarioBean = new ArrayList<CuestionarioBean>();
    ArrayList<FilterBeanHelper> alFilterBeanHelper = ParameterCook.prepareFilter(oRequest);
    HashMap<String, String> hmOrder = ParameterCook.prepareOrder(oRequest);

    alCuestionarioBean = oCuestionarioDao.getsolocuestionario(alFilterBeanHelper, hmOrder);
    GsonBuilder gsonBuilder = new GsonBuilder();
    gsonBuilder.setDateFormat("dd/MM/yyyy");
    Gson gson = gsonBuilder.create();/* www .  j av a 2 s .c o  m*/
    String data = "{\"status\":200,\"message\":" + gson.toJson(alCuestionarioBean) + "}";
    return data;
}

From source file:net.daw.service.specific.implementation.DetallePedidoServiceSpImpl.java

License:Open Source License

@Override
public String get(Integer id) throws Exception {
    String data = null;/*from  ww w  .ja  va  2 s.  c o  m*/
    try {
        oConnection.setAutoCommit(false);
        DetallePedidoDaoSpcImpl oDetallePedidoDAO = new DetallePedidoDaoSpcImpl(strObjectName, oConnection);
        DetallePedidoBeanGenSpImpl oDetallePedido = new DetallePedidoBeanGenSpImpl(id);
        oDetallePedido = oDetallePedidoDAO.get(oDetallePedido, AppConfigurationHelper.getJsonDepth());
        GsonBuilder gsonBuilder = new GsonBuilder();
        gsonBuilder.setDateFormat("dd/MM/yyyy");
        Gson gson = gsonBuilder.create();
        data = gson.toJson(oDetallePedido);
        oConnection.commit();
    } catch (Exception ex) {
        oConnection.rollback();
        ExceptionBooster.boost(new Exception(this.getClass().getName() + ":get ERROR: " + ex.getMessage()));
    }
    return data;
}

From source file:net.daw.service.specific.implementation.DetallePedidoServiceSpImpl.java

License:Open Source License

@Override
public String getPage(int intRegsPerPag, int intPage, ArrayList<FilterBeanHelper> alFilter,
        HashMap<String, String> hmOrder) throws Exception {
    String data = null;/*from   w  w w.  ja va2 s .  co  m*/
    try {
        oConnection.setAutoCommit(false);
        DetallePedidoDaoSpcImpl oDetallePedidoDAO = new DetallePedidoDaoSpcImpl(strObjectName, oConnection);
        List<DetallePedidoBeanGenSpImpl> oDetallePedidos = oDetallePedidoDAO.getPage(intRegsPerPag, intPage,
                alFilter, hmOrder);
        GsonBuilder gsonBuilder = new GsonBuilder();
        gsonBuilder.setDateFormat("dd/MM/yyyy");
        Gson gson = gsonBuilder.create();
        data = gson.toJson(oDetallePedidos);
        data = "{\"list\":" + data + "}";
        oConnection.commit();
    } catch (Exception ex) {
        oConnection.rollback();
        ExceptionBooster.boost(new Exception(this.getClass().getName() + ":getPage ERROR: " + ex.getMessage()));
    }
    return data;
}

From source file:net.daw.service.specific.implementation.DirectorServiceSpImpl.java

License:Open Source License

@Override
public String get(Integer id) throws Exception {
    String data = null;//from   w  w  w .  j a  va2  s. c o  m
    try {
        oConnection.setAutoCommit(false);
        DirectorDaoSpcImpl oDirectorDAO = new DirectorDaoSpcImpl(strObjectName, oConnection);
        DirectorBeanGenSpImpl oDirector = new DirectorBeanGenSpImpl(id);
        oDirector = oDirectorDAO.get(oDirector, 1);
        GsonBuilder gsonBuilder = new GsonBuilder();
        gsonBuilder.setDateFormat("dd/MM/yyyy");
        Gson gson = gsonBuilder.create();
        data = gson.toJson(oDirector);
        oConnection.commit();
    } catch (Exception ex) {
        oConnection.rollback();
        ExceptionBooster.boost(new Exception(this.getClass().getName() + ":get ERROR: " + ex.getMessage()));
    }
    return data;
}

From source file:net.daw.service.specific.implementation.DirectorServiceSpImpl.java

License:Open Source License

@Override
public String getPage(int intRegsPerPag, int intPage, ArrayList<FilterBeanHelper> alFilter,
        HashMap<String, String> hmOrder) throws Exception {
    String data = null;/*from w w  w  .  ja v  a 2 s .  c om*/
    try {
        oConnection.setAutoCommit(false);
        DirectorDaoSpcImpl oDirectorDAO = new DirectorDaoSpcImpl(strObjectName, oConnection);
        List<DirectorBeanGenSpImpl> oDirectors = oDirectorDAO.getPage(intRegsPerPag, intPage, alFilter,
                hmOrder);
        GsonBuilder gsonBuilder = new GsonBuilder();
        gsonBuilder.setDateFormat("dd/MM/yyyy");
        Gson gson = gsonBuilder.create();
        data = gson.toJson(oDirectors);
        data = "{\"list\":" + data + "}";
        oConnection.commit();
    } catch (Exception ex) {
        oConnection.rollback();
        ExceptionBooster.boost(new Exception(this.getClass().getName() + ":getPage ERROR: " + ex.getMessage()));
    }
    return data;
}

From source file:net.daw.service.specific.implementation.DocumentoService.java

License:MIT License

public String getcuestionario() throws Exception {

    Connection oConnection = new BoneConnectionPoolImpl().newConnection();

    DocumentoDao oDocumentoDao = new DocumentoDao(oConnection);
    ArrayList<CuestionarioBean> alDocumentoBean = new ArrayList();
    int id = ParameterCook.prepareId(oRequest);

    DocumentoBean oDocumentoBean = new DocumentoBean();
    oDocumentoBean.setId(id);/*from ww  w  . j av  a 2 s .c o  m*/

    alDocumentoBean = oDocumentoDao.getCuestionario(oDocumentoBean);
    GsonBuilder gsonBuilder = new GsonBuilder();
    gsonBuilder.setDateFormat("dd/MM/yyyy");
    Gson gson = gsonBuilder.create();
    String data = "{\"status\":200,\"message\":" + gson.toJson(alDocumentoBean) + "}";

    return data;
}