Example usage for org.joda.time.format DateTimeFormat forPattern

List of usage examples for org.joda.time.format DateTimeFormat forPattern

Introduction

In this page you can find the example usage for org.joda.time.format DateTimeFormat forPattern.

Prototype

public static DateTimeFormatter forPattern(String pattern) 

Source Link

Document

Factory to create a formatter from a pattern string.

Usage

From source file:bison.solutions.hazelcast.HazelcastConnection.java

private void putCourtsInHazelcast(InputStream stream) {
    try (InputStreamReader inputStreamReader = new InputStreamReader(stream);
            BufferedReader bufferedReader = new BufferedReader(inputStreamReader)) {

        String line;/* www.  j av  a  2 s .  c om*/
        bufferedReader.readLine();
        Court court = null;
        String key = "";
        while ((line = bufferedReader.readLine()) != null) {
            try {
                String[] values = line.split(",");
                court = new Court();
                DateTimeFormatter dtf = DateTimeFormat.forPattern("MM/dd/yyyy");

                key = values[0];
                key = key.toUpperCase();
                court.setMunicipality(key);
                court.setMunicipalCourt(values[1]);
                court.setMunicipalWebsite(values[2]);
                court.setMunicipalCourtWebsite(values[3]);
                court.setClerkPhoneNumber(values[5]);
                if (!values[6].equals("N/A") && !values[6].equals(""))
                    court.setOnlinePayment(true);
                else
                    court.setOnlinePayment(false);

                hazelcastInstance.getMap(CourtNamespace).put(key, court);
            } catch (ArrayIndexOutOfBoundsException e) {
                hazelcastInstance.getMap(CourtNamespace).put(key, court);
            }
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:bison.solutions.hazelcast.HazelcastConnection.java

private void putCitationsInHazelcast(InputStream citation) {

    try (InputStreamReader inputStreamReader = new InputStreamReader(citation);
            BufferedReader bufferedReader = new BufferedReader(inputStreamReader)) {

        String line;/*from www . j  a v a 2 s. c  om*/
        bufferedReader.readLine();
        Citation citationToPutInHaz = null;
        String key = "";
        while ((line = bufferedReader.readLine()) != null) {
            try {
                String[] values = line.split(",");
                citationToPutInHaz = new Citation();
                DateTimeFormatter dtf = DateTimeFormat.forPattern("MM/dd/yyyy");

                key = values[0];
                citationToPutInHaz.setCitationNumber(Integer.parseInt(values[1]));
                citationToPutInHaz.setFirstName(values[3]);
                citationToPutInHaz.setLastName(values[4]);
                citationToPutInHaz.setDefendentAddress(values[6]);
                citationToPutInHaz.setDefendentCity(values[7]);
                citationToPutInHaz.setDefendentState(values[8]);
                citationToPutInHaz.setDriversLicenseNumber(values[9]);
                citationToPutInHaz.setCourtLocation(values[11]);
                citationToPutInHaz.setCourtAddress(values[12]);

                try {
                    citationToPutInHaz.setCitationDate(new Date(dtf.parseMillis(values[2].split(" ")[0])));
                } catch (IllegalArgumentException e) {
                    /*literally cancer*/}
                try {
                    citationToPutInHaz.setDateOfBirth(new Date(dtf.parseMillis(values[5].split(" ")[0])));
                } catch (IllegalArgumentException e) {
                    /*literally cancer*/}
                try {
                    citationToPutInHaz.setCourtDate(new Date(dtf.parseMillis(values[10].split(" ")[0])));
                } catch (IllegalArgumentException e) {
                    /*literally cancer*/}

                hazelcastInstance.getMap(CitationNamespace).put(key, citationToPutInHaz);
            } catch (ArrayIndexOutOfBoundsException e) {
                hazelcastInstance.getMap(CitationNamespace).put(key, citationToPutInHaz);
            }
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:bison.solutions.hazelcast.HazelcastConnection.java

private void putViolationsInHazelcast(InputStream violation) {
    try (InputStreamReader inputStreamReader = new InputStreamReader(violation);
            BufferedReader bufferedReader = new BufferedReader(inputStreamReader)) {

        String line;/*w  w  w . j a va 2s. co  m*/
        bufferedReader.readLine();
        while ((line = bufferedReader.readLine()) != null) {
            String[] values = line.split(",");
            Violation violationToPutInHaz = new Violation();
            DateTimeFormatter dtf = DateTimeFormat.forPattern("MM/dd/yyyy");

            String key = values[0];
            try {
                violationToPutInHaz.setCitationNumber(Long.parseLong(values[1]));
                violationToPutInHaz.setViolationNumber(values[2]);
                violationToPutInHaz.setViolationDescription(values[3]);
                violationToPutInHaz.setWarrantStatus(parseTOrF(values[4]));
                violationToPutInHaz.setWarrantNumber(values[5]);
                try {
                    violationToPutInHaz.setStatus(Violation.Status.valueOf(values[6]));
                } catch (IllegalArgumentException ex) {
                    /* */ }
                violationToPutInHaz.setStatusDate(new Date(dtf.parseMillis(values[7])));
                violationToPutInHaz.setFineAmount(values[8]);
                violationToPutInHaz.setCourtCost(values[9]);
            } catch (ArrayIndexOutOfBoundsException e) {
            }

            hazelcastInstance.getMap(ViolationNamespace).put(key, violationToPutInHaz);
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:br.com.bob.dashboard.web.util.Utils.java

private DateTimeFormatter getDefaultJoda() {
    return DateTimeFormat.forPattern(pattern);
}

From source file:br.com.caelum.mvc.logica.AlteraContatoLinkLogic.java

@Override
public void executa(HttpServletRequest req, HttpServletResponse res) throws Exception {
    DateTimeFormatter fmt = DateTimeFormat.forPattern("dd/MM/YYYY");
    Long id = Long.parseLong(req.getParameter("id"));
    ContatoDao contatoDao = new ContatoDao();
    Contato contato = contatoDao.getContato(id);
    req.setAttribute("id", contato.getId());
    req.setAttribute("nome", contato.getNome());
    req.setAttribute("email", contato.getEmail());
    req.setAttribute("endereco", contato.getEndereco());
    req.setAttribute("datanasc", contato.getDataNascimento().toString(fmt));
    RequestDispatcher rd = req.getRequestDispatcher("altera-contato.jsp");
    rd.forward(req, res);// ww w.ja va2s.  co  m
}

From source file:br.com.objectos.blog.PostImpl.java

License:Apache License

@Override
public String getPath() {
    DateTime date = getDate();/*  www.  jav a 2  s .c  o  m*/
    DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy/MM/dd");
    String directoryName = formatter.print(date);

    String title = getTitle();
    String filename;
    filename = Strings.accentsToAscii(title).alphanum().whitespaceTo("_").toString().toLowerCase();

    return directoryName + "/" + filename + ".html";
}

From source file:br.com.objectos.blog.PostImpl.java

License:Apache License

private void writeTo0(PostTemplate template, File destination) throws IOException {

    String html = render(template);

    DateTime date = getDate();//from ww  w .  j a  v a 2s . c om
    DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy/MM/dd");
    String directoryName = formatter.print(date);

    File directory = new File(destination, directoryName);
    directory.mkdirs();

    String title = getTitle();
    String filename = Strings.accentsToAscii(title).alphanum().whitespaceTo("_").toString().toLowerCase();

    File file = new File(directory, filename + ".html");
    Files.write(html, file, Charsets.UTF_8);

}

From source file:br.com.objectos.blog.PostTemplateImpl.java

License:Apache License

@Override
public void setDate(DateTime date) {
    DateTimeFormatter formatter = DateTimeFormat.forPattern("dd/MM/yyyy HH:mm");
    tryToSet(PostTag.DATE, formatter.print(date));
}

From source file:br.edu.utfpr.cm.JGitMinerWeb.services.metric.AllMetricServices.java

private DateTime getDateTimeFromString(String strParam) {
    DateTimeFormatter formatter = DateTimeFormat.forPattern("dd/MM/yyyy HH:mm:ss");
    //Sun Jun 01 00:00:00 BRT 2014
    String[] str = strParam.split(" ");

    DateTime date = new DateTime(
            formatter.parseDateTime(str[2] + "/" + getMes(str[1]) + "/" + str[5] + " " + str[3]));

    return date;/*from  ww w .  j a v  a2s  . c  o  m*/
}

From source file:br.eti.ranieri.opcoesweb.page.PainelOpcoes.java

License:Apache License

public PainelOpcoes(String id, List<CotacaoOpcao> opcoes, LocalDate atualizacao) {
    this(id, opcoes, atualizacao,
            DateTimeFormat.forPattern("'Atualizado em 'dd/MM/yyyy").withLocale(ptBR).print(atualizacao));
}