List of usage examples for org.joda.time LocalDate LocalDate
public LocalDate()
From source file:$.MessageController.java
License:Apache License
@RequestMapping(value = "/{msgId}/log", method = RequestMethod.GET) public String getLogOfMsgByMsgId(@PathVariable("msgId") Long msgId, Model model) { Message msg = messageService.findMessageById(msgId); model.addAttribute("requestMsgId", msgId); if (msg != null) { String correlationId = msg.getCorrelationId(); model.addAttribute("correlationId", correlationId); List<String> logLines = new ArrayList<String>(); try { long start = System.currentTimeMillis(); SortedSet<LocalDate> logDates = getMsgDates(msg); logDates.add(new LocalDate()); // adding today just in case Log.debug("Starts searching log for correlationId = " + correlationId); for (LocalDate logDate : logDates) { logLines.addAll(messageLogParser.getLogLines(correlationId, logDate.toDate())); }//from w ww.j a va 2s. c o m Log.debug("Finished searching log in " + (System.currentTimeMillis() - start) + " ms."); model.addAttribute("log", StringUtils.join(logLines, "${symbol_escape}n")); } catch (IOException ex) { model.addAttribute("logErr", "Error occurred during reading log file: " + ex.getMessage()); } } return "msgLog"; }
From source file:app.sunstreak.yourpisd.util.DateHelper.java
License:Open Source License
public static String daysRelative(DateTime dt) { while (dt.isBefore(startOfSchoolYear)) dt = dt.plusYears(1);/*from w w w . j ava2 s .c om*/ // if today if (dt.toLocalDate().isEqual(new LocalDate())) return "(today)"; Period pd; if (dt.isBeforeNow()) pd = new Interval(dt, new LocalDate().toDateTimeAtStartOfDay()).toPeriod(); else pd = new Interval(new LocalDate().toDateTimeAtStartOfDay(), dt).toPeriod(); StringBuilder sb = new StringBuilder("\n("); int compare = dt.compareTo(new DateTime()); sb.append(pf.print(pd)); // Compare to now. if (dt.isBeforeNow()) sb.append(" ago)"); else sb.append(" from now)"); return sb.toString(); }
From source file:at.jclehner.rxdroid.preferences.DatePreference.java
License:Open Source License
public DatePreference(Context context, AttributeSet attrs) { super(context, attrs); setDefaultValue(new LocalDate()); setPositiveButtonText(android.R.string.ok); setNegativeButtonText(android.R.string.cancel); }
From source file:au.edu.uws.eresearch.cr8it.TransformationHandler.java
License:Apache License
private String getJsonMapping(String jsonString) throws IOException, ParseException { String template = readFile("./template.json"); JSONParser parser = new JSONParser(); JSONObject original = (JSONObject) parser.parse(template); JSONObject manifest = (JSONObject) parser.parse(jsonString); JSONObject dataObject = (JSONObject) original.get("data"); JSONArray dataArray = (JSONArray) dataObject.get("data"); JSONArray creators = (JSONArray) manifest.get("creators"); JSONArray activities = (JSONArray) manifest.get("activities"); JSONArray vfs = (JSONArray) manifest.get("vfs"); LocalDate today = new LocalDate(); int creatorIndex = 1; int grantIndex = 1; for (Object data : dataArray) { ((JSONObject) data).put("datasetId", jsonString.hashCode()); JSONObject tfpackage = (JSONObject) ((JSONObject) data).get("tfpackage"); tfpackage.put("dc:created", today.toString()); Object root = vfs.get(0); if (root != null) { String crateName = (String) ((JSONObject) root).get("name"); tfpackage.put("dc:title", crateName); tfpackage.put("title", crateName); }/* ww w . j a v a 2 s . c o m*/ for (Object creator : creators) { //TODO we might need to split the name into first and last name String name = (String) ((JSONObject) creator).get("name"); tfpackage.put("dc:creator.foaf:Person." + creatorIndex + ".foaf:name", name); String identifier = (String) ((JSONObject) creator).get("identifier"); tfpackage.put("dc:creator.foaf:Person." + creatorIndex + ".dc:identifier", identifier); creatorIndex++; } for (Object activity : activities) { String identifier = (String) ((JSONObject) activity).get("identifier"); tfpackage.put("foaf:fundedBy.vivo:Grant." + grantIndex + ".dc:identifier", identifier); String grantNumber = (String) ((JSONObject) activity).get("grant_number"); tfpackage.put("foaf:fundedBy.vivo:Grant." + grantIndex + ".redbox:grantNumber", grantNumber); String title = (String) ((JSONObject) activity).get("title"); String repositoryName = (String) ((JSONObject) activity).get("repository_name"); tfpackage.put("foaf:fundedBy.vivo:Grant." + grantIndex + ".skos:prefLabel", "(" + repositoryName + ") " + title); grantIndex++; } } String updatedJson = original.toJSONString(); return updatedJson; }
From source file:au.id.hazelwood.xmltvguidebuilder.mapper.XmltvMapper.java
License:Apache License
public Tv toXmltv(ChannelListings channelListings) { LOGGER.debug("Creating TV"); StopWatch stopWatch = new StopWatch(); stopWatch.start();//from w w w . j a va2s . c om Tv tv = OBJECT_FACTORY.createTv(); tv.setDate(DATE_FORMAT.print(new LocalDate())); tv.setSourceInfoName(format("{0} {1}", applicationName, applicationVersion)); tv.setGeneratorInfoName(format("{0} {1}", applicationName, applicationVersion)); for (ChannelDetail channelDetail : channelListings.getChannels()) { tv.getChannel().add(createChannel(channelDetail)); for (ProgrammeDetail programmeDetail : channelListings.getPrograms(channelDetail.getId())) { tv.getProgramme().add(createProgramme(channelDetail, programmeDetail)); } } stopWatch.stop(); LOGGER.debug("Created tv in {}", formatDurationWords(stopWatch.getTime())); return tv; }
From source file:br.com.moonjava.flight.util.VerifierString.java
License:Apache License
public static boolean isBirthDay(String word, String country) { boolean birthDay = false; LocalDate date = FormatDateTimeDesk.parseToLocalDate(word, country); boolean leapYear = new GregorianCalendar().isLeapYear(date.getYear()); LocalDate now = new LocalDate(); // US MM/DD/YYYY if (country.equals("US")) { // No pode conter 30 e 31 em fevereiro e nem ser maior que a data atual if (!word.startsWith("02/30") && !word.startsWith("02/31") && date.isBefore(now) || date.isEqual(now)) { // Se for bissexto deve considerar 02/29 if (word.startsWith("02/29") && leapYear || !word.startsWith("02/29")) { Pattern pattern = Pattern.compile("(0[1-9]|1[012])/(0[1-9]|[12][0-9]|3[01])/((19|20)\\d\\d)"); Matcher matcher = pattern.matcher(word); birthDay = matcher.find(); }//w w w . j ava 2 s .c o m } // BR DD/MM/YYYY } else { if (!word.startsWith("30/02") && !word.startsWith("31/02") && date.isBefore(now) || date.isEqual(now)) { // No pode conter 30 e 31 em fevereiro e nem ser maior que a data atual if (word.startsWith("29/02") && leapYear || !word.startsWith("29/02")) { // Se for bissexto deve considerar 29/02 Pattern pattern = Pattern.compile("(0[1-9]|[12][0-9]|3[01])/(0[1-9]|1[012])/((19|20)\\d\\d)"); Matcher matcher = pattern.matcher(word); birthDay = matcher.find(); } } } return birthDay; }
From source file:br.com.moonjava.flight.util.VerifierString.java
License:Apache License
public static boolean isValidate(String word) { try {/* www . ja v a 2s .c om*/ boolean validate = false; LocalDate now = new LocalDate(); String year = word.substring(3, 7); String month = word.substring(0, 2); LocalDate date = new LocalDate().withYear(Integer.parseInt(year)) .withMonthOfYear(Integer.parseInt(month)); if (date.isAfter(now) || date.isEqual(now)) { Pattern pattern = Pattern.compile("(0[1-9]|1[012])/((19|20)\\d\\d)"); Matcher matcher = pattern.matcher(word); validate = matcher.find(); } return validate; } catch (IllegalFieldValueException e) { return false; } }
From source file:br.com.objectos.jabuticava.debs.Caracteristica.java
License:Apache License
static Caracteristica vazio() { LocalDate data = new LocalDate(); List<Record> registros = ImmutableList.of(); return new Caracteristica("", data, registros); }
From source file:br.eti.ranieri.opcoesweb.importacao.online.ImportadorOnlineBanif.java
License:Apache License
CotacaoAcaoOpcoes converterCalcularBlackScholes(ConfiguracaoOnline configuracao, Acao acao, CotacaoBDI ultimaCotacaoAcao) throws Exception { LocalDate hoje = new LocalDate(); Serie serieAtualOpcoes = Serie.getSerieAtualPorData(hoje); List<CotacaoBDI> opcoesSerie1 = obterOpcoes(configuracao, acao, serieAtualOpcoes, hoje); Serie proximaSerieOpcoes = Serie.getProximaSeriePorData(hoje); List<CotacaoBDI> opcoesSerie2 = obterOpcoes(configuracao, acao, proximaSerieOpcoes, hoje); CotacaoBDI opcaoTeorica1 = new CotacaoBDI(hoje, CodigoBDI.OPCOES_DE_COMPRA, TipoMercadoBDI.OPCOES_DE_COMPRA, "Terica", 0, 0, 0, ultimaCotacaoAcao.getFechamento(), opcoesSerie1.iterator().next().getDataVencimento()); CotacaoBDI opcaoTeorica2 = new CotacaoBDI(hoje, CodigoBDI.OPCOES_DE_COMPRA, TipoMercadoBDI.OPCOES_DE_COMPRA, "Terica", 0, 0, 0, ultimaCotacaoAcao.getFechamento(), opcoesSerie2.iterator().next().getDataVencimento()); Double selic = taxaSelic.getSelic(hoje); return blackScholes.calcularIndices(ultimaCotacaoAcao, serieAtualOpcoes, opcoesSerie1, opcaoTeorica1, proximaSerieOpcoes, opcoesSerie2, opcaoTeorica2, 10, selic); }
From source file:ca.krasnay.scaffold.Scaffold.java
License:Apache License
/** * Returns map of fields to be merged into the template. Subclasses may * override this to return their own map, but should in general call this * base class method and augment and return the default map. *//*from ww w. j a v a 2s . c o m*/ public Map<String, Object> getMergeFields() { Map<String, Object> map = new LinkedHashMap<String, Object>(); String packageName = entityClass.getPackage().getName(); String entityName = entityClass.getSimpleName(); List<Field> fields = new ArrayList<Field>(); for (Field field : entityClass.getDeclaredFields()) { if (!Modifier.isStatic(field.getModifiers())) { fields.add(field); } } map.put("package", packageName); map.put("Entity", entityName); map.put("entity", entityName.substring(0, 1).toLowerCase() + entityName.substring(1)); map.put("fields", fields); map.put("date", new LocalDate().toString()); map.put("scaffold", this); return map; }