List of usage examples for java.time LocalDate getMonthValue
public int getMonthValue()
From source file:Main.java
public static void main(String[] args) { LocalDate a = LocalDate.of(2014, 6, 30); System.out.println(a.getMonthValue()); }
From source file:Main.java
public static void main(String[] args) { // Human Readable LocalDate date = LocalDate.now(); System.out.println(String.format("%s-%s-%s", date.getYear(), date.getMonthValue(), date.getDayOfMonth())); }
From source file:Main.java
public static void main(String[] argv) { LocalDate today = LocalDate.now(); System.out.println(String.format("Year : %s Month : %s day : %s", today.getYear(), today.getMonthValue(), today.getDayOfMonth()));//from ww w. ja v a 2 s. com LocalDateTime time = LocalDateTime.now(); System.out.println( String.format("Hour : %s Mins : %s Sec : %s", time.getHour(), time.getMinute(), time.getSecond())); }
From source file:com.marklogic.tableauextract.ExtractFromJSON.java
/** * Read JSON output from MarkLogic REST extension or *.xqy file and insert * the output into a Tabeleau table/* w ww.ja v a 2 s. co m*/ * * @param table * @throws TableauException */ private static void insertData(Table table) throws TableauException, FileNotFoundException, ParseException, IOException { TableDefinition tableDef = table.getTableDefinition(); Row row = new Row(tableDef); URL url = new URL("http://localhost:8060/json.xqy"); BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(url.openStream())); JSONParser jsonParser = new JSONParser(); JSONObject jsonObject = (JSONObject) jsonParser.parse(bufferedReader); JSONArray claims = (JSONArray) jsonObject.get("claims"); @SuppressWarnings("unchecked") Iterator<JSONObject> i = claims.iterator(); while (i.hasNext()) { JSONObject innerObject = i.next(); String idString = (String) innerObject.get("id"); row.setInteger(0, Integer.parseInt(idString.substring(0, 6))); row.setCharString(1, (String) innerObject.get("ssn")); row.setCharString(2, (String) innerObject.get("type")); String payString = (String) innerObject.get("payment_amount"); if (payString == null || payString.isEmpty()) payString = "0.0"; row.setDouble(3, Double.parseDouble(payString)); String dtString = (String) innerObject.get("claim_date"); if (dtString == null || dtString.isEmpty()) dtString = "1999-01-01"; LocalDate claimDate = (LocalDate.parse(dtString)); row.setDate(4, claimDate.getYear(), claimDate.getMonthValue(), claimDate.getDayOfMonth()); table.insert(row); } /* row.setDateTime( 0, 2012, 7, 3, 11, 40, 12, 4550); // Purchased row.setCharString(1, "Beans"); // Product row.setString( 2, "uniBeans"); // uProduct row.setDouble( 3, 1.08); // Price row.setDate( 6, 2029, 1, 1); // Expiration date row.setCharString(7, "Bohnen"); // Produkt for ( int i = 0; i < 10; ++i ) { row.setInteger(4, i * 10); // Quantity row.setBoolean(5, i % 2 == 1); // Taxed } */ }
From source file:ch.algotrader.option.OptionSymbol.java
/** * Generates the ISIN for the specified {@link ch.algotrader.entity.security.OptionFamily}. *//*w ww . j a va 2 s. c o m*/ public static String getIsin(OptionFamily family, LocalDate expiration, OptionType type, BigDecimal strike) { String week = family.isWeekly() ? DateTimePatterns.WEEK_OF_MONTH.format(expiration) : ""; String month; if (OptionType.CALL.equals(type)) { month = monthCallEnc[expiration.getMonthValue() - 1]; } else { month = monthPutEnc[expiration.getMonthValue() - 1]; } int yearIndex = expiration.getYear() % 10; String year = yearEnc[yearIndex]; String strike36 = BaseConverterUtil.toBase36(strike.multiply(new BigDecimal(10)).intValue()); String strikeVal = strike.scale() + StringUtils.leftPad(strike36, 4, "0"); StringBuilder buffer = new StringBuilder(); buffer.append("1O"); buffer.append(family.getIsinRoot() != null ? family.getIsinRoot() : family.getSymbolRoot()); buffer.append(week); buffer.append(month); buffer.append(year); buffer.append(strikeVal); return buffer.toString(); }
From source file:ch.algotrader.option.OptionSymbol.java
/** * Generates the RIC for the specified {@link ch.algotrader.entity.security.OptionFamily}. *//*from w ww. j a v a 2s. c om*/ public static String getRic(OptionFamily family, LocalDate expiration, OptionType type, BigDecimal strike) { StringBuilder buffer = new StringBuilder(); buffer.append(family.getRicRoot() != null ? family.getRicRoot() : family.getSymbolRoot()); if (OptionType.CALL.equals(type)) { buffer.append(monthCallEnc[expiration.getMonthValue() - 1]); } else { buffer.append(monthPutEnc[expiration.getMonthValue() - 1]); } buffer.append(DateTimePatterns.DAY_OF_MONTH.format(expiration)); final String s = DateTimePatterns.YEAR_4_DIGIT.format(expiration); buffer.append(s.substring(s.length() - 2, s.length())); buffer.append(StringUtils.leftPad(String.valueOf((int) (strike.doubleValue() * 100)), 5, "0")); buffer.append(".U"); return buffer.toString(); }
From source file:daylightchart.daylightchart.calculation.RiseSetUtility.java
/** * Generate a year's worth of dates// w w w . j a va 2 s . c o m * * @return All the dates for the year */ private static List<LocalDate> getYearsDates(final int year) { final List<LocalDate> dates = new ArrayList<LocalDate>(); LocalDate date = LocalDate.of(year, 1, 1); do { dates.add(date); date = date.plusDays(1); } while (!(date.getMonthValue() == 1 && date.getDayOfMonth() == 1)); return dates; }
From source file:ch.algotrader.option.OptionSymbol.java
/** * Generates the symbole for the specified {@link ch.algotrader.entity.security.OptionFamily}. * * Example// w w w. j av a2 s . co m * <table> * <tr><td><b>Pattern</b></td><td><b>Description</b></td><td><b>Example</b></td></tr> * <tr><td>N</td><td>Name</td><td>CrudeOil</td></tr> * <tr><td>CR</td><td>SymbolRoot</td><td>CL</td></tr> * <tr><td>C</td><td>Currency</td><td>USD</td></tr> * <tr><td>CS</td><td>ContractSize</td><td>1000</td></tr> * <tr><td>M</td><td>Month 1-digit</td><td>6</td></tr> * <tr><td>MM</td><td>Month 2-digit</td><td>06</td></tr> * <tr><td>MMM</td><td>Month Short</td><td>JUN</td></tr> * <tr><td>MMMM</td><td>Month Long</td><td>June</td></tr> * <tr><td>YY</td><td>Year 2-digit</td><td>16</td></tr> * <tr><td>YYYY</td><td>Year 4-digit</td><td>2016</td></tr> * <tr><td>W</td><td>Week of Month</td><td>3</td></tr> * <tr><td>T</td><td>Type Short</td><td>C</td></tr> * <tr><td>TT</td><td>Type Long</td><td>CALL</td></tr> * <tr><td>S</td><td>Strike</td><td>500</td></tr> * </table> */ public static String getSymbol(OptionFamily family, LocalDate expiration, OptionType type, BigDecimal strike, String pattern) { String[] placeHolders = new String[] { "N", "SR", "CS", "C", "MMMM", "MMM", "MM", "MR", "YYYY", "YY", "YR", "W", "TT", "T", "S" }; String[] values = new String[] { family.getName(), family.getSymbolRoot(), RoundUtil.getBigDecimal(family.getContractSize(), 0).toString(), family.getCurrency().toString(), DateTimePatterns.MONTH_LONG.format(expiration).toUpperCase(), DateTimePatterns.MONTH_SHORT.format(expiration).toUpperCase(), DateTimePatterns.MONTH_2_DIGIT.format(expiration).toUpperCase(), OptionType.CALL.equals(type) ? monthCallEnc[expiration.getMonth().getValue() - 1] : monthPutEnc[expiration.getMonthValue() - 1], DateTimePatterns.YEAR_4_DIGIT.format(expiration), DateTimePatterns.YEAR_2_DIGIT.format(expiration), yearEnc[expiration.getYear() % 10], DateTimePatterns.WEEK_OF_MONTH.format(expiration), type.toString(), type.toString().substring(0, 1), strike.toString() }; return StringUtils.replaceEach(pattern, placeHolders, values); }
From source file:no.imr.stox.functions.acoustic.PgNapesIO.java
public static void convertPgNapesToLuf20(String path, String fileName, String outFileName) { try {/*from www.j a v a2 s . co m*/ List<String> acList = Files.readAllLines(Paths.get(path + "/" + fileName + ".txt")); List<String> acVList = Files.readAllLines(Paths.get(path + "/" + fileName + "Values.txt")); if (acList.isEmpty() || acVList.isEmpty()) { return; } acList.remove(0); acVList.remove(0); List<DistanceBO> dList = acList.stream().map(s -> { DistanceBO d = new DistanceBO(); String[] str = s.split("\t", 14); d.setNation(str[0]); d.setPlatform(str[1]); d.setCruise(str[2]); d.setLog_start(Conversion.safeStringtoDoubleNULL(str[3])); d.setStart_time(Date.from(LocalDateTime.of(Conversion.safeStringtoIntegerNULL(str[4]), Conversion.safeStringtoIntegerNULL(str[5]), Conversion.safeStringtoIntegerNULL(str[6]), Conversion.safeStringtoIntegerNULL(str[7]), Conversion.safeStringtoIntegerNULL(str[8]), 0) .toInstant(ZoneOffset.UTC))); d.setLat_start(Conversion.safeStringtoDoubleNULL(str[9])); d.setLon_start(Conversion.safeStringtoDoubleNULL(str[10])); d.setIntegrator_dist(Conversion.safeStringtoDoubleNULL(str[11])); FrequencyBO freq = new FrequencyBO(); d.getFrequencies().add(freq); freq.setTranceiver(1); // implicit in pgnapes freq.setUpper_interpret_depth(0d); freq.setUpper_integrator_depth(0d); freq.setDistance(d); freq.setFreq(Conversion.safeStringtoIntegerNULL(str[12])); freq.setThreshold(Conversion.safeStringtoDoubleNULL(str[13])); return d; }).collect(Collectors.toList()); // Fill in sa values acVList.forEach(s -> { String[] str = s.split("\t", 11); String cruise = str[2]; Double log = Conversion.safeStringtoDoubleNULL(str[3]); Integer year = Conversion.safeStringtoIntegerNULL(str[4]); Integer month = Conversion.safeStringtoIntegerNULL(str[5]); Integer day = Conversion.safeStringtoIntegerNULL(str[6]); if (log == null || year == null || month == null || day == null) { return; } DistanceBO d = dList.parallelStream().filter(di -> { if (di.getCruise() == null || di.getLog_start() == null || di.getStart_time() == null) { return false; } LocalDate ld = di.getStart_time().toInstant().atZone(ZoneOffset.UTC).toLocalDate(); return cruise.equals(di.getCruise()) && log.equals(di.getLog_start()) && year.equals(ld.getYear()) && month.equals(ld.getMonthValue()) && day.equals(ld.getDayOfMonth()); }).findFirst().orElse(null); if (d == null) { return; } FrequencyBO freq = d.getFrequencies().get(0); String species = str[7]; Integer acocat = PgNapesEchoConvert.getAcoCatFromPgNapesSpecies(species); Double chUppDepth = Conversion.safeStringtoDoubleNULL(str[8]); Double chLowDepth = Conversion.safeStringtoDoubleNULL(str[9]); Double sa = Conversion.safeStringtoDoubleNULL(str[10]); if (acocat == null || sa == null || sa == 0d || chLowDepth == null || chUppDepth == null) { return; } if (d.getPel_ch_thickness() == null) { d.setPel_ch_thickness(chLowDepth - chUppDepth); } Integer ch = (int) (chLowDepth / d.getPel_ch_thickness() + 0.5); SABO sabo = new SABO(); sabo.setFrequency(freq); freq.getSa().add(sabo); sabo.setAcoustic_category(acocat + ""); sabo.setCh_type("P"); sabo.setCh(ch); sabo.setSa(sa); }); // Calculate number of pelagic channels /*dList.stream().forEach(d -> { FrequencyBO f = d.getFrequencies().get(0); Integer minCh = f.getSa().stream().map(SABO::getCh).min(Integer::compare).orElse(null); Integer maxCh = f.getSa().stream().map(SABO::getCh).max(Integer::compare).orElse(null); if (maxCh != null && minCh != null) { f.setNum_pel_ch(maxCh - minCh + 1); } });*/ if (dList.isEmpty()) { return; } DistanceBO d = dList.get(0); String cruise = d.getCruise(); String nation = d.getNation(); String pl = d.getPlatform(); ListUser20Writer.export(cruise, nation, pl, path + "/" + cruise + outFileName + ".xml", dList); } catch (IOException ex) { Logger.getLogger(PgNapesIO.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:daylightchart.daylightchart.calculation.RiseSetUtility.java
@SuppressWarnings("boxing") private static RawRiseSet calculateRiseSet(final Location location, final LocalDate date, final boolean useDaylightTime, final boolean inDaylightSavings, final TwilightType twilight) { if (location != null) { sunAlgorithm.setLocation(location.getDescription(), location.getPointLocation().getLatitude().getDegrees(), location.getPointLocation().getLongitude().getDegrees()); sunAlgorithm/* w ww .j ava 2s . co m*/ .setTimeZoneOffset(DefaultTimezones.getStandardTimeZoneOffsetHours(location.getTimeZoneId())); } sunAlgorithm.setDate(date.getYear(), date.getMonthValue(), date.getDayOfMonth()); final double[] sunriseSunset = sunAlgorithm.calcRiseSet(twilight.getHorizon()); if (useDaylightTime && inDaylightSavings) { if (!Double.isInfinite(sunriseSunset[0])) { sunriseSunset[0] = sunriseSunset[0] + 1; } if (!Double.isInfinite(sunriseSunset[1])) { sunriseSunset[1] = sunriseSunset[1] + 1; } } final RawRiseSet riseSet = new RawRiseSet(location, date, useDaylightTime && inDaylightSavings, sunriseSunset[0], sunriseSunset[1]); return riseSet; }