List of usage examples for org.joda.time LocalDateTime getDayOfMonth
public int getDayOfMonth()
From source file:control.LivroController.java
public static List<String> volumeToString(Volume v) { if (v != null) { Volume.VolumeInfo volumeInfo = v.getVolumeInfo(); Volume.SaleInfo saleInfo = v.getSaleInfo(); LocalDateTime ldt; Volume.VolumeInfo.ImageLinks links = null; String smallThumbLink = ""; String title = ""; String author = ""; String genr = ""; String identifier = ""; String pageCount = ""; String price = ""; String rating = ""; String publisher = ""; String description = ""; /* Link da thumb */ links = volumeInfo.getImageLinks(); if (links != null) smallThumbLink = links.getSmallThumbnail(); /* Ttulo */ title = "" + v.getVolumeInfo().getTitle() + ""; if (v.getVolumeInfo().getSubtitle() != null) title = title.concat(" - " + v.getVolumeInfo().getSubtitle()); /* Autores */ java.util.List<String> authors = v.getVolumeInfo().getAuthors(); if (authors != null && !authors.isEmpty()) { for (int i = 0; i < authors.size(); ++i) { author = authors.get(i); if (i < authors.size() - 1) { author = author.concat(", "); }// www .j av a 2 s .c om } } /* Editora e Data de publicao */ if (volumeInfo.getPublisher() != null) publisher = volumeInfo.getPublisher(); if (volumeInfo.getPublishedDate() != null) { ldt = new LocalDateTime(volumeInfo.getPublishedDate()); publisher = publisher .concat(", " + +ldt.getDayOfMonth() + "/" + ldt.getMonthOfYear() + "/" + ldt.getYear()); } /* Descrio */ if (volumeInfo.getDescription() != null) description = "Descrio: " + volumeInfo.getDescription() + ""; /* Gneros */ java.util.List<String> genrs = volumeInfo.getCategories(); if (genrs != null && !genrs.isEmpty()) { genr = genr.concat("Genro: "); if (volumeInfo.getMainCategory() != null) genr = genr.concat(volumeInfo.getMainCategory() + ", "); for (int i = 0; i < genrs.size(); ++i) { genr = genr.concat(genrs.get(i)); if (i < genrs.size() - 1) { genr = genr.concat(", "); } } } /* Nmero de pginas */ if (volumeInfo.getPageCount() != null) pageCount = "" + volumeInfo.getPageCount() + " pginas"; /* Identificadores */ java.util.List<Volume.VolumeInfo.IndustryIdentifiers> isbn = volumeInfo.getIndustryIdentifiers(); if (isbn != null && !isbn.isEmpty()) { for (Volume.VolumeInfo.IndustryIdentifiers ii : isbn) { identifier = identifier.concat(ii.getType() + ": " + ii.getIdentifier() + ""); } } /* Avaliaes */ if (volumeInfo.getRatingsCount() != null && volumeInfo.getRatingsCount() > 0) { int fullRating = (int) Math.round(volumeInfo.getAverageRating()); rating = "Avaliao: "; for (int i = 0; i < fullRating; ++i) { rating = rating.concat(" * "); } rating = rating.concat(" (" + volumeInfo.getRatingsCount() + " avaliaes) "); } /* Informaes de Venda */ if (saleInfo != null && "FOR_SALE".equals(saleInfo.getSaleability())) { double save = saleInfo.getListPrice().getAmount() - saleInfo.getRetailPrice().getAmount(); if (save > 0.0) { price = price.concat( "Preo mdio: " + CURRENCY_FORMATTER.format(saleInfo.getListPrice().getAmount())); } price = price.concat( ", na Google Books: " + CURRENCY_FORMATTER.format(saleInfo.getRetailPrice().getAmount())); if (save > 0.0) { price = price.concat(", voc ganha: " + CURRENCY_FORMATTER.format(save) + " (" + PERCENT_FORMATTER.format(save / saleInfo.getListPrice().getAmount()) + ")"); } } List<String> details = Arrays.asList(identifier, // 0 title, // 1 author, // 2 genr, // 3 rating, // 4 price, // 5 pageCount, // 6 publisher, // 7 description, // 8 smallThumbLink); // 9 return details; } return null; }
From source file:de.avanux.smartapplianceenabler.appliance.TimeOfDayOfWeek.java
License:Open Source License
public LocalDateTime toNextOccurrence(LocalDateTime now) { LocalDateTime dateTime = new LocalDateTime(now.getYear(), now.getMonthOfYear(), now.getDayOfMonth(), getHour(), getMinute(), getSecond()); while (dateTime.get(DateTimeFieldType.dayOfWeek()) != dayOfWeek) { dateTime = dateTime.plusDays(1); }/*from ww w . j a v a 2 s . c om*/ return dateTime; }
From source file:de.avanux.smartapplianceenabler.appliance.TimeOfDayOfWeek.java
License:Open Source License
public LocalDateTime toLastOccurrence(LocalDateTime now) { LocalDateTime dateTime = new LocalDateTime(now.getYear(), now.getMonthOfYear(), now.getDayOfMonth(), getHour(), getMinute(), getSecond()); while (dateTime.get(DateTimeFieldType.dayOfWeek()) != dayOfWeek) { dateTime = dateTime.minusDays(1); }//w ww.j av a 2 s . c o m return dateTime; }
From source file:de.javakaffee.kryoserializers.jodatime.JodaLocalDateTimeSerializer.java
License:Apache License
@Override public void write(Kryo kryo, Output output, LocalDateTime localDateTime) { final int packedYearMonthDay = localDateTime.getYear() * 13 * 32 + localDateTime.getMonthOfYear() * 32 + localDateTime.getDayOfMonth(); output.writeLong((long) packedYearMonthDay * 86400000 + localDateTime.getMillisOfDay(), true); final String chronologyId = IdentifiableChronology.getChronologyId(localDateTime.getChronology()); output.writeString(chronologyId == null ? "" : chronologyId); }
From source file:de.jpaw.bonaparte.util.DayTime.java
License:Apache License
/** Converts the day portion of a LocalDate or localDateTime into a number in the format YYYYMMDD. */ static public int dayAsInt(LocalDateTime when) { return when.getDayOfMonth() + 100 * when.getMonthOfYear() + 10000 * when.getYear(); }
From source file:ee.ut.soras.ajavtV2.Main.java
License:Open Source License
/** * Loob etteantud sisends6ne p6hjal referentsaja: granulaarsuste <i>aasta, kuu, kuupaev, * tund, minut</i> vaartuste j2rjendi. Kui sisends6ne ei rahulda regulaaravaldisi * <code>/[0-9X]{4}-[0-9X]{2}-[0-9X]{2}T[0-9X]{2}:[0-9X]{2}/</code> vi * <code>/[0-9X]{4}-[0-9X]{2}-[0-9X]{2}/</code> , tagastatakse null. * Kui sisends6ne on null, luuakse referentsaja j2rjend minuti-t2psusega hetkeaja p6hjal. * <br><br> // ww w .jav a 2 s . c om * Tagastatud j2rjendis on granulaarsuste vaartused j2rjekorras * <i>aasta, kuu, kuupaev, tund, minut</i>. */ public static String[] looSonePohjalReferentsAeg(String sone) { if (sone != null) { if (sone.matches("[0-9X]{4}-[0-9X]{2}-[0-9X]{2}T[0-9X]{2}:[0-9X]{2}")) { // 1) Kui sisends6ne vastab etteantud mustrile String[] kalendriValjadeVaartused = new String[5]; int j = 0; boolean seenXXXvalues = false; StringTokenizer tokens1 = new StringTokenizer(sone, "-:T"); while (tokens1.hasMoreTokens()) { String s = (String) tokens1.nextToken(); if (j < kalendriValjadeVaartused.length) { kalendriValjadeVaartused[j] = s; } if (s.matches("X+")) { seenXXXvalues = true; } else { if (seenXXXvalues) { // Kui on l2bisegi numbrid ja XX-v22rtused, on tegemist mitte- // koosk6lalise sisendajaga: parandame numbrid XX-ideks kalendriValjadeVaartused[j] = "XX"; } } if (j < kalendriValjadeVaartused.length) { j++; } } return kalendriValjadeVaartused; } else if (sone.matches("^[0-9X]{4}-[0-9X]{2}-[0-9X]{2}$")) { // 2) Kui sisends6ne vastab etteantud mustrile String[] kalendriValjadeVaartused = new String[5]; int j = 0; boolean seenXXXvalues = false; StringTokenizer tokens2 = new StringTokenizer(sone, "-"); while (tokens2.hasMoreTokens()) { String s = (String) tokens2.nextToken(); if (j < kalendriValjadeVaartused.length) { kalendriValjadeVaartused[j] = s; } if (s.matches("X+")) { seenXXXvalues = true; } else { if (seenXXXvalues) { // Kui on l2bisegi numbrid ja XX-v22rtused, on tegemist mitte- // koosk6lalise sisendajaga: parandame numbrid XX-ideks kalendriValjadeVaartused[j] = "XX"; } } if (j < kalendriValjadeVaartused.length) { j++; } } // Viimased (kellaaja osa) ongi selle mustri puhul teadmata kalendriValjadeVaartused[3] = "XX"; kalendriValjadeVaartused[4] = "XX"; return kalendriValjadeVaartused; } return null; } else { // 2) Kui sisends6ne puudub v6i ei vasta etteantud mustrile, loome uue // referentsaja, milleks saab hetkeaeg LocalDateTime hetkeAeg = new LocalDateTime(); String[] kalendriValjadeVaartused = new String[5]; kalendriValjadeVaartused[0] = String.valueOf(hetkeAeg.getYear()); kalendriValjadeVaartused[1] = String.valueOf(hetkeAeg.getMonthOfYear()); kalendriValjadeVaartused[2] = String.valueOf(hetkeAeg.getDayOfMonth()); kalendriValjadeVaartused[3] = String.valueOf(hetkeAeg.getHourOfDay()); kalendriValjadeVaartused[4] = String.valueOf(hetkeAeg.getMinuteOfHour()); for (int i = 1; i < kalendriValjadeVaartused.length; i++) { if (kalendriValjadeVaartused[i].length() == 1) { kalendriValjadeVaartused[i] = "0" + kalendriValjadeVaartused[i]; } } return kalendriValjadeVaartused; } }
From source file:org.apache.isis.applib.fixturescripts.clock.ClockFixture.java
License:Apache License
@Override protected void execute(ExecutionContext ec) { // can only be used in the context of integration tests if (!(Clock.getInstance() instanceof FixtureClock)) { throw new IllegalStateException("Clock has not been initialized as a FixtureClock"); }/*from ww w. j a v a2 s . com*/ final FixtureClock fixtureClock = (FixtureClock) FixtureClock.getInstance(); // check that some value has been set checkParam("date", ec, String.class); // process if can be parsed as a LocalDateTime LocalDateTime ldt = parseAsLocalDateTime(date); if (ldt != null) { fixtureClock.setDate(ldt.getYear(), ldt.getMonthOfYear(), ldt.getDayOfMonth()); fixtureClock.setTime(ldt.getHourOfDay(), ldt.getMinuteOfHour()); return; } // else process if can be parsed as a LocalDate LocalDate ld = parseAsLocalDate(date); if (ld != null) { fixtureClock.setDate(ld.getYear(), ld.getMonthOfYear(), ld.getDayOfMonth()); return; } // else throw new IllegalArgumentException( String.format("'%s' could not be parsed as a local date/time or local date", date)); }
From source file:org.apache.isis.applib.fixturescripts.clock.TickingClockFixture.java
License:Apache License
private void setTo(final String date) { if (!(Clock.getInstance() instanceof FixtureClock)) { throw new IllegalStateException("Clock has not been initialized as a FixtureClock"); }/*from ww w .j a v a 2 s. c o m*/ final FixtureClock fixtureClock = (FixtureClock) FixtureClock.getInstance(); // process if can be parsed as a LocalDateTime LocalDateTime ldt = parseAsLocalDateTime(date); if (ldt != null) { fixtureClock.setDate(ldt.getYear(), ldt.getMonthOfYear(), ldt.getDayOfMonth()); fixtureClock.setTime(ldt.getHourOfDay(), ldt.getMinuteOfHour()); return; } // else process if can be parsed as a LocalDate LocalDate ld = parseAsLocalDate(date); if (ld != null) { fixtureClock.setDate(ld.getYear(), ld.getMonthOfYear(), ld.getDayOfMonth()); return; } // else throw new IllegalArgumentException( String.format("'%s' could not be parsed as a local date/time or local date", date)); }
From source file:org.apache.isis.schema.utils.jaxbadapters.JodaLocalDateTimeXMLGregorianCalendarAdapter.java
License:Apache License
public static XMLGregorianCalendar print(final LocalDateTime dateTime) { if (dateTime == null) return null; final XMLGregorianCalendarImpl xgc = new XMLGregorianCalendarImpl(); xgc.setYear(dateTime.getYear());/*w w w. ja v a 2 s . c om*/ xgc.setMonth(dateTime.getMonthOfYear()); xgc.setDay(dateTime.getDayOfMonth()); xgc.setHour(dateTime.getHourOfDay()); xgc.setMinute(dateTime.getMinuteOfHour()); xgc.setSecond(dateTime.getSecondOfMinute()); xgc.setMillisecond(dateTime.getMillisOfSecond()); return xgc; }
From source file:org.apache.isis.schema.utils.jaxbadapters.XmlCalendarFactory.java
License:Apache License
public static XMLGregorianCalendar create(LocalDateTime localDateTime) { return localDateTime != null ? withTypeFactoryDo(dtf -> dtf.newXMLGregorianCalendar(localDateTime.getYear(), localDateTime.getMonthOfYear(), localDateTime.getDayOfMonth(), localDateTime.getHourOfDay(), localDateTime.getMinuteOfHour(), localDateTime.getSecondOfMinute(), localDateTime.getMillisOfSecond(), DatatypeConstants.FIELD_UNDEFINED)) : null; }