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.MensajeprivadoServiceSpImpl.java

License:Open Source License

@Override
public String get(Integer id) throws Exception {
    String data = null;// ww w .  j  a  v  a 2  s  .  c o  m
    try {
        oConnection.setAutoCommit(false);
        MensajeprivadoDaoSpcImpl oMensajeprivadoDAO = new MensajeprivadoDaoSpcImpl(strObjectName, oConnection);
        MensajeprivadoBeanGenSpImpl oMensajeprivado = new MensajeprivadoBeanGenSpImpl(id);
        oMensajeprivado = oMensajeprivadoDAO.get(oMensajeprivado, AppConfigurationHelper.getJsonDepth());
        GsonBuilder gsonBuilder = new GsonBuilder();
        gsonBuilder.setDateFormat("dd/MM/yyyy HH:mm:ss");
        Gson gson = gsonBuilder.create();
        data = gson.toJson(oMensajeprivado);
        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.MensajeprivadoServiceSpImpl.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 .  j  av a2 s  .com
    try {
        oConnection.setAutoCommit(false);
        MensajeprivadoDaoSpcImpl oMensajeprivadoDAO = new MensajeprivadoDaoSpcImpl(strObjectName, oConnection);
        List<MensajeprivadoBeanGenSpImpl> oMensajeprivados = oMensajeprivadoDAO.getPage(intRegsPerPag, intPage,
                alFilter, hmOrder);
        GsonBuilder gsonBuilder = new GsonBuilder();
        gsonBuilder.setDateFormat("dd/MM/yyyy HH:mm:ss");
        Gson gson = gsonBuilder.create();
        data = gson.toJson(oMensajeprivados);
        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.OpcionService.java

License:MIT License

@Override
public String get() throws Exception {

    int id = ParameterCook.prepareId(oRequest);

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

    OpcionDao oOpcionDao = new OpcionDao(oConnection);

    OpcionBean oOpcionBean = new OpcionBean();
    oOpcionBean.setId(id);// ww  w. j  av  a2 s .  co  m

    oOpcionBean = oOpcionDao.get(oOpcionBean, 1);
    GsonBuilder gsonBuilder = new GsonBuilder();
    gsonBuilder.setDateFormat("dd/MM/yyyy HH:mm:ss");
    Gson gson = gsonBuilder.create();
    String data = gson.toJson(oOpcionBean);

    return "{\"status\":200,\"message\":" + data + "}";
}

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

License:MIT License

@Override
public String getall() throws Exception {

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

    OpcionDao oOpcionDao = new OpcionDao(oConnection);
    ArrayList<OpcionBean> alOpcionBean = new ArrayList<OpcionBean>();
    ArrayList<FilterBeanHelper> alFilterBeanHelper = ParameterCook.prepareFilter(oRequest);
    HashMap<String, String> hmOrder = ParameterCook.prepareOrder(oRequest);

    alOpcionBean = oOpcionDao.getAll(alFilterBeanHelper, hmOrder);
    GsonBuilder gsonBuilder = new GsonBuilder();
    gsonBuilder.setDateFormat("dd/MM/yyyy");
    Gson gson = gsonBuilder.create();/*from w w w .j  a v  a2s .c om*/
    String data = "{\"status\":200,\"message\":" + gson.toJson(alOpcionBean) + "}";

    return data;
}

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

License:Open Source License

@Override
public String get(Integer id) throws Exception {
    String data = null;//from   w  w  w. jav a  2s.  c o  m
    try {
        oConnection.setAutoCommit(false);
        OrdenadorDaoSpcImpl oOrdenadorDAO = new OrdenadorDaoSpcImpl(strObjectName, oConnection);
        OrdenadorBeanGenSpImpl oOrdenador = new OrdenadorBeanGenSpImpl(id);
        oOrdenador = oOrdenadorDAO.get(oOrdenador, AppConfigurationHelper.getJsonDepth());
        GsonBuilder gsonBuilder = new GsonBuilder();
        gsonBuilder.setDateFormat("dd/MM/yyyy");
        Gson gson = gsonBuilder.create();
        data = gson.toJson(oOrdenador);
        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.OrdenadorServiceSpImpl.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  .  jav a2s . c o m*/
    try {
        oConnection.setAutoCommit(false);
        OrdenadorDaoSpcImpl oOrdenadorDAO = new OrdenadorDaoSpcImpl(strObjectName, oConnection);
        List<OrdenadorBeanGenSpImpl> oOrdenadors = oOrdenadorDAO.getPage(intRegsPerPag, intPage, alFilter,
                hmOrder);
        GsonBuilder gsonBuilder = new GsonBuilder();
        gsonBuilder.setDateFormat("dd/MM/yyyy");
        Gson gson = gsonBuilder.create();
        data = gson.toJson(oOrdenadors);
        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.PeliculaServiceSpImpl.java

License:Open Source License

@Override
public String get(Integer id) throws Exception {
    String data = null;//from w w w.  ja va2 s. co m
    try {
        oConnection.setAutoCommit(false);
        PeliculaDaoSpcImpl oPeliculaDAO = new PeliculaDaoSpcImpl(strObjectName, oConnection);
        PeliculaBeanGenSpImpl oPelicula = new PeliculaBeanGenSpImpl(id);
        oPelicula = oPeliculaDAO.get(oPelicula, 1);
        GsonBuilder gsonBuilder = new GsonBuilder();
        gsonBuilder.setDateFormat("dd/MM/yyyy");
        Gson gson = gsonBuilder.create();
        data = gson.toJson(oPelicula);
        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.PeliculaServiceSpImpl.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 www  . j a v  a2 s.c  o m
    try {
        oConnection.setAutoCommit(false);
        PeliculaDaoSpcImpl oPeliculaDAO = new PeliculaDaoSpcImpl(strObjectName, oConnection);
        List<PeliculaBeanGenSpImpl> oPeliculas = oPeliculaDAO.getPage(intRegsPerPag, intPage, alFilter,
                hmOrder);
        GsonBuilder gsonBuilder = new GsonBuilder();
        gsonBuilder.setDateFormat("dd/MM/yyyy");
        Gson gson = gsonBuilder.create();
        data = gson.toJson(oPeliculas);
        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.PostServiceSpImpl.java

License:Open Source License

@Override
public String get(Integer id) throws Exception {
    String data = null;//from  ww w .j a  va 2  s .co m
    try {
        oConnection.setAutoCommit(false);
        PostDaoSpcImpl oPostDAO = new PostDaoSpcImpl(strObjectName, oConnection);
        PostBeanGenSpImpl oPost = new PostBeanGenSpImpl(id);
        oPost = oPostDAO.get(oPost, AppConfigurationHelper.getJsonDepth());
        GsonBuilder gsonBuilder = new GsonBuilder();
        gsonBuilder.setDateFormat("dd/MM/yyyy HH:mm:ss");
        Gson gson = gsonBuilder.create();
        data = gson.toJson(oPost);
        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.PostServiceSpImpl.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 av a2  s.c om*/
    try {
        oConnection.setAutoCommit(false);
        PostDaoSpcImpl oPostDAO = new PostDaoSpcImpl(strObjectName, oConnection);
        List<PostBeanGenSpImpl> oPosts = oPostDAO.getPage(intRegsPerPag, intPage, alFilter, hmOrder);
        GsonBuilder gsonBuilder = new GsonBuilder();
        gsonBuilder.setDateFormat("dd/MM/yyyy HH:mm:ss");
        Gson gson = gsonBuilder.create();
        data = gson.toJson(oPosts);
        data = "{\"list\":" + data + "}";
        oConnection.commit();
    } catch (Exception ex) {
        oConnection.rollback();
        ExceptionBooster.boost(new Exception(this.getClass().getName() + ":getPage ERROR: " + ex.getMessage()));
    }
    return data;
}