Example usage for org.joda.time DateTime DateTime

List of usage examples for org.joda.time DateTime DateTime

Introduction

In this page you can find the example usage for org.joda.time DateTime DateTime.

Prototype

public DateTime(Object instant) 

Source Link

Document

Constructs an instance from an Object that represents a datetime.

Usage

From source file:betalabs.libtests.unfolding.AnimatedTemporalDotsApp.java

License:Open Source License

public void draw() {
    background(0);/*from  w w  w.  j av a 2s. com*/
    map.draw();

    for (Marker marker : markers) {
        DateTime markerTime = new DateTime(marker.getProperty("date"));
        if (markerTime.isBefore(currentTime)) {
            ScreenPosition pos = map.getScreenPosition(marker.getLocation());

            drawGrowingEarthquakeDots(pos, markerTime);
        }
    }

    // Each 4 frame (and if currently animating)
    if (animating) {
        currentTime = currentTime.plusMinutes(10);
        // Loop: If end is reached start at beginning again.
        if (currentTime.isAfter(endTime)) {
            currentTime = startTime.plus(0);
        }
    }

    noStroke();
    fill(0, 200);
    rect(10, 10, 270, 20);
    fill(255);
    text("Time: " + currentTime, 13, 24);
}

From source file:br.com.bob.dashboard.model.Metric.java

public String getInactiveTime() {
    final DateTime old = new DateTime(date);
    final DateTime now = new DateTime();
    final Period period = new Period(old, now);

    int interval;
    if ((interval = period.getDays()) > 0)
        return getText(interval, "dia(s)");

    else if ((interval = period.getHours()) > 0)
        return getText(interval, "hora(s)");

    else if ((interval = period.getMinutes()) > 0)
        return getText(interval, "minuto(s)");
    else//  w w  w  .  java  2s . co m
        return "h pouco";
}

From source file:br.com.caelum.agenda.servlet.AdicionaContatoServlet.java

@Override
protected void service(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    PrintWriter out = response.getWriter();
    String nome = request.getParameter("nome");
    String endereco = request.getParameter("endereco");
    String email = request.getParameter("email");
    String dataEmTexto = request.getParameter("dataNascimento");
    DateTime datanasc;/* ww w.j a v a 2  s  .  c o  m*/
    try {
        Date date = new SimpleDateFormat("dd/MM/yyyy").parse(dataEmTexto);
        datanasc = new DateTime(date.getTime());
    } catch (ParseException e) {

        out.println("Erro de converso da data");
        return; //para a execuo do mtodo
    }

    Contato contato = new Contato();
    contato.setNome(nome);
    contato.setEndereco(endereco);
    contato.setEmail(email);
    contato.setDataNascimento(datanasc);

    ContatoDao dao = new ContatoDao();
    dao.adiciona(contato);
    RequestDispatcher rd = request.getRequestDispatcher("/contato-adicionado.jsp");
    rd.forward(request, response);
}

From source file:br.com.fidias.chance4j.Chance.java

License:Open Source License

/**
 * Generate a random datetime, between min and max.
 *
 * @param min Minimum value to choose from
 * @param max Maximum value to choose from
 * @return A random datetime//from  www. j a v a2  s  . c om
 * @throws ChanceException
 */
private DateTime dateTime(long min, long max) throws ChanceException {
    if (min < 1) {
        throw new ChanceException("Min value must be greater than zero.");
    }
    long value = getLong(min, max);
    return new DateTime(value);
}

From source file:br.com.hyperclass.parking.config.ParkingContextBean.java

License:Open Source License

@Bean
public List<ParkingEvent> parkingEvents() {
    final List<ParkingEvent> parkingEvents = new LinkedList<>();
    final Vehicle v1 = new Vehicle("gfsa-6543", "Civic", VehicleColor.GRAY, VehicleType.CAR);
    final Vehicle v2 = new Vehicle("dgka-7431", "Xj6", VehicleColor.BLACK, VehicleType.MOTORCYCLE);
    parkingEvents.add(new VehicleEntryEventTest(1, v1, new DateTime(1477933200000l)));
    parkingEvents.add(new VehicleOutputEvent(1, v1, new DateTime(1477934400000l), 1.5));
    parkingEvents.add(new VehicleEntryEventTest(2, v2, new DateTime(1477999380000l)));
    parkingEvents.add(new VehicleOutputEvent(2, v2, new DateTime(1478002980000l), 2));
    return parkingEvents;
}

From source file:br.com.locadora.DAO.AluguelDAO.java

/**
 * Calcula o valor total do aluguel/*from  w w w  . j a  v a 2s  .c o m*/
 * @param aluguelPendente
 * @param dataDevolucao
 * @return 
 */
private Double calcularValorTotal(Aluguel aluguelPendente, Date dataDevolucao) {
    int quantFilmes = aluguelPendente.getFilmes().size();
    DateTime dateAluguel = new DateTime(aluguelPendente.getDataAluguel().getTime());
    DateTime dateDevolucao = new DateTime(dataDevolucao);
    int diferencaDias = Days.daysBetween(dateAluguel, dateDevolucao).getDays();
    int diasAtraso = diferencaDias - 2 - (quantFilmes - 1);
    Double multa = 1.2 * (diasAtraso > 0 ? diasAtraso : 0);
    Double valorTotal = aluguelPendente.getValor() + multa;
    return valorTotal;
}

From source file:br.com.moonjava.flight.jdbc.ResultSetJdbcWrapper.java

License:Apache License

@Override
public DateTime getDateTime(String columnLabel) {
    try {// ww  w  .  j  av  a2 s.c om
        Timestamp timestamp = rs.getTimestamp(alias + "." + columnLabel);
        return new DateTime(timestamp);
    } catch (SQLException e) {
        throw new RuntimeException(e);
    }
}

From source file:br.com.objectos.blog.syntax.MetaDateTimeType.java

License:Apache License

@Override
public DateTime toValue(String text) {
    try {//from ww  w . j  a  va  2  s.co m
        return new DateTime(text);
    } catch (IllegalArgumentException e) {
        throw new InvalidMetaValueException(
                "Couldn't parse %META:" + getKey() + "% value " + text + " to a date time.", e);
    }
}

From source file:br.com.objectos.comuns.relational.jdbc.TypeDateTime.java

License:Apache License

@Override
DateTime getValue(ResultSet rs) throws SQLException {
    Timestamp date = rs.getTimestamp("VALUE");
    return date != null ? new DateTime(date) : null;
}

From source file:br.com.postalis.folhapgto.proc.TelaPrincipal.java

private void carregarParametros() {
    this.dtRef = new DateTime(anoRef.getYear() + "-" + (mesRef.getMonth() + 1) + "-" + "01").toDate();
    this.anoMesRef = Long
            .parseLong(anoRef.getYear() + StringsUtil.getLpad("" + (mesRef.getMonth() + 1), 2, "0"));
    this.txtMesAno = (mesRef.getMonth() + 1) + "/" + anoRef.getYear();
}