Example usage for org.joda.time Days getDays

List of usage examples for org.joda.time Days getDays

Introduction

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

Prototype

public int getDays() 

Source Link

Document

Gets the number of days that this period represents.

Usage

From source file:se3prac8.SE3Prac8.java

public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    String line = s.nextLine();//from   w  w w . j av a2 s  .  co m
    DateTime parsedDate = null;
    // TODO code application logic here
    if (charCheck(line)) {
        if (line.indexOf(".") != -1) {
            parsedDate = parseYFrac(line);
        } else {
            parsedDate = d_wM_y(line);
        }
    } else {
        if (line.length() >= 8) {
            parsedDate = parseYMD(line);
        } else if (line.length() <= 4) {
            System.out.println("IsRunning");
            parsedDate = new DateTime(Integer.parseInt(line), 1, 1, 0, 0);
        } else {
            System.out.println("Error");
        }
    }
    Days days;

    days = Days.daysBetween(unixTime, parsedDate);
    long secondsPassed = days.getDays() * secInDay;

    System.out.println(secondsPassed);
}

From source file:utils.DateUtils.java

License:Open Source License

public static boolean isGreateThan(Date lesser, Date bigger) {
    if (lesser == null || bigger == null)
        return false;

    Days days = Days.daysBetween(new DateTime(bigger), new DateTime(lesser));
    return (days.getDays() > 0);
}

From source file:utils.DateUtils.java

License:Open Source License

public static boolean isLessThan(Date lesser, Date bigger) {
    if (lesser == null || bigger == null)
        return false;

    Days days = Days.daysBetween(new DateTime(bigger), new DateTime(lesser));
    return (days.getDays() <= 0);
}

From source file:View.FormExtratoMultas.java

private void inicializarPainel() {

    jEPMultas.setContentType("text/html");

    String HTML = "";

    HTMLEditorKit editorKit = (HTMLEditorKit) jEPMultas.getEditorKit();
    StyleSheet ss = new StyleSheet();
    Enumeration e = editorKit.getStyleSheet().getStyleNames();
    while (e.hasMoreElements()) {
        ss.addRule(e.nextElement().toString());
    }/*ww  w  .  ja  va2s . co  m*/
    ss.addRule("table {font-family: Latin Modern Math, LM Math; font-size: 10px; align: right; width: 100%}");
    ss.addRule(
            "th {font-family: Latin Modern Math, LM Math; font-size: 10px; font-weight:bold; text-align: center; outline-width: 0px; margin: 0px;  border-width: 1px; border-style: solid; border-color: #000000;}");
    ss.addRule(
            "td {font-family: Latin Modern Math, LM Math; font-size: 10px; padding: 3px; margin: 0px; border-width: 1px; border-style: solid; border-color: #000000;}");
    jEPMultas.setDocument(new HTMLDocument(ss));

    if (multaList == null || multaList.isEmpty()) {
        Aviso.showError("Nenhuma multa selecionada.");
        return;
    }

    multaList.sort(new Multa());

    int idAtual;
    int idPassado = -1;
    int rowCount = 1;
    double total = 0;

    HTML = HTML.concat("<table>");
    for (Multa multaVO : multaList) {
        Pessoa pessoaResponsavel;
        if (multaVO.getPessoa() == null)
            pessoaResponsavel = multaVO.getCarteira().getTitular();
        else
            pessoaResponsavel = multaVO.getPessoa();

        idAtual = pessoaResponsavel.getIdPessoa();

        if (idAtual != idPassado) {
            if (idPassado != -1) {
                HTML = totalMultaPessoa(HTML, total);
            }
            rowCount = 1;
            total = 0;
            HTML = HTML.concat("<tr style=\"background-color:#FFFFFF\"></tr>");

            HTML = HTML.concat("<tr style=\"background-color:#0080FF\">" + "<th width=\"100%\" colspan=\"7\">"
                    + pessoaResponsavel.getNome() + "</th>" + "</tr>");

            HTML = HTML.concat(
                    "<tr style= \"background-color:#3399FF\" >" + "<th > Placa </th>" + "<th > Infrao </th>"
                            + "<th > Pontuao </th>" + "<th > Data da Ocorrncia </th>" + "<th > Atraso </th>"
                            + "<th > Valor Original </th>" + "<th > Valor Final </th>" + "</tr>");
        }

        Automovel auto = multaVO.getAutomovel();
        Autuacao autuacao = multaVO.getAutuacao();

        Date emissao = multaVO.getDataEmissao();
        boolean temAtraso;

        DateTime dataInicio = new DateTime(emissao);
        DateTime dataFinal = new DateTime();

        Days dias = Days.daysBetween(dataInicio, dataFinal);

        temAtraso = dias.getDays() > autuacao.getPrazo();

        SimpleDateFormat formataData = new SimpleDateFormat("dd/MM/yyyy");
        String date = formataData.format(emissao);

        double custoReal = MultaController.calcularMulta(multaVO, temAtraso);
        total += custoReal;

        HTML = HTML.concat("<tr style= "
                + ((rowCount % 2 == 0) ? "\"background-color:#99CCFF\" " : "\"background-color:#CCE5FF\" ")
                + ">" + "<th >" + auto.getPlaca() + "</th>" + "<th >" + autuacao.getTitulo() + "</th>" + "<th >"
                + autuacao.getPontuacao() + "</th>" + "<th >" + date + "</th>" + "<th >"
                + ((temAtraso) ? "Atrasado!" : "OK!") + "</th>" + "<th >" + "R$ " + autuacao.getCusto()
                + "</th>" + "<th >" + "R$ " + custoReal + "</th>" + "</tr>");

        idPassado = idAtual;
        rowCount++;
    }

    HTML = totalMultaPessoa(HTML, total);
    HTML = HTML.concat("</table>");

    jEPMultas.setText(HTML);

}