List of usage examples for java.time LocalDate getDayOfMonth
public int getDayOfMonth()
From source file:Main.java
public static void main(String[] args) { LocalDate a = LocalDate.of(2014, 6, 30); System.out.println(a.getDayOfMonth()); }
From source file:Main.java
public static void main(String[] argv) { LocalDate date1 = LocalDate.now(); LocalDate date2 = LocalDate.of(date1.getYear(), date1.getMonth(), date1.getDayOfMonth()); if (date1.equals(date2)) { System.out.printf("Today %s and date1 %s are same date %n", date1, date2); }//from ww w . j av a 2 s . c o m }
From source file:Main.java
public static void main(String[] argv) { LocalDate dateOfBirth = LocalDate.now(); MonthDay birthday = MonthDay.of(dateOfBirth.getMonth(), dateOfBirth.getDayOfMonth()); MonthDay currentMonthDay = MonthDay.from(LocalDate.now()); if (currentMonthDay.equals(birthday)) { System.out.println("Yes!!"); } else {/*from w w w . j a v a 2s.c om*/ System.out.println("Sorry, today is not your birthday"); } }
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())); LocalDateTime time = LocalDateTime.now(); System.out.println(/*from ww w.ja va2s. co m*/ String.format("Hour : %s Mins : %s Sec : %s", time.getHour(), time.getMinute(), time.getSecond())); }
From source file:Main.java
public static void main(String[] args) { LocalDate localDate = LocalDate.of(2014, 6, 21); int year = localDate.getYear(); System.out.println(year);//from w w w.jav a 2s . c o m Month month = localDate.getMonth(); System.out.println(month); int day = localDate.getDayOfMonth(); System.out.println(day); }
From source file:Main.java
public static void main(String[] args) { LocalDate date = LocalDate.of(2014, 2, 15); // 2014-02-15 // ISO-8601 standard // the day-of-week to represent, from 1 (Monday) to 7 (Sunday) DayOfWeek dayOfWeek = date.getDayOfWeek(); System.out.println(dayOfWeek); // SATURDAY System.out.println(DayOfWeek.of(3)); // WEDNESDAY System.out.println(dayOfWeek.getValue()); // 6 System.out.println(dayOfWeek.name()); // SATURDAY System.out.println(date.getDayOfMonth()); // 15 System.out.println(date.atStartOfDay()); // 2014-02-15 00:00 System.out.println("DayOfWeek"); dayOfWeek = DayOfWeek.FRIDAY; Locale locale = Locale.getDefault(); System.out.println(dayOfWeek.getDisplayName(TextStyle.FULL, locale)); // Friday System.out.println(dayOfWeek.getDisplayName(TextStyle.NARROW, locale)); // F System.out.println(dayOfWeek.getDisplayName(TextStyle.SHORT, locale)); // Fri }
From source file:cz.pichlik.goodsentiment.MockDataGenerator.java
public static LocalDateTime generateTimestamp(LocalDate seed) { return of(seed.getYear(), seed.getMonth(), seed.getDayOfMonth(), 0, 0).plusHours(rg().nextInt(23)) .plusMinutes(rg().nextInt(59)).plusSeconds(rg().nextInt(59)); }
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/* ww w. ja va2s .c o 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:net.ceos.project.poi.annotated.bean.MultiTypeObjectBuilder.java
/** * Validate the MultiTypeObject based on the object build with the method * 'buildMultiTypeObject'/* w w w . j a v a 2 s.c om*/ * * @param toValidate * the object to validate */ public static void validateMultiTypeObject(MultiTypeObject toValidate) { MultiTypeObject base = buildMultiTypeObject(); Calendar calendar = Calendar.getInstance(); calendar.setTime(new Date()); Calendar calendarUnmarshal = Calendar.getInstance(); calendarUnmarshal.setTime(toValidate.getDateAttribute()); assertEquals(calendar.get(Calendar.YEAR), calendarUnmarshal.get(Calendar.YEAR)); assertEquals(calendar.get(Calendar.MONTH), calendarUnmarshal.get(Calendar.MONTH)); assertEquals(calendar.get(Calendar.DAY_OF_MONTH), calendarUnmarshal.get(Calendar.DAY_OF_MONTH)); LocalDate localDate = LocalDate.now(); assertEquals(localDate.getDayOfMonth(), toValidate.getLocalDateAttribute().getDayOfMonth()); assertEquals(localDate.getMonth(), toValidate.getLocalDateAttribute().getMonth()); assertEquals(localDate.getYear(), toValidate.getLocalDateAttribute().getYear()); LocalDateTime localDateTime = LocalDateTime.now(); assertEquals(localDateTime.getDayOfMonth(), toValidate.getLocalDateTimeAttribute().getDayOfMonth()); assertEquals(localDateTime.getMonth(), toValidate.getLocalDateTimeAttribute().getMonth()); assertEquals(localDateTime.getYear(), toValidate.getLocalDateTimeAttribute().getYear()); assertEquals(localDateTime.getHour(), toValidate.getLocalDateTimeAttribute().getHour()); /* it is possible to have an error below due the time of execution of the test */ assertEquals(localDateTime.getMinute(), toValidate.getLocalDateTimeAttribute().getMinute()); assertEquals(base.getStringAttribute(), toValidate.getStringAttribute()); assertEquals(base.getIntegerAttribute(), toValidate.getIntegerAttribute()); assertEquals(base.getDoubleAttribute(), toValidate.getDoubleAttribute()); assertEquals(base.getLongAttribute(), toValidate.getLongAttribute()); assertEquals(base.getBooleanAttribute(), toValidate.getBooleanAttribute()); assertEquals(base.getJob().getJobCode(), toValidate.getJob().getJobCode()); assertEquals(base.getJob().getJobFamily(), toValidate.getJob().getJobFamily()); assertEquals(base.getJob().getJobName(), toValidate.getJob().getJobName()); assertEquals(base.getIntegerPrimitiveAttribute(), toValidate.getIntegerPrimitiveAttribute()); assertEquals(base.getDoublePrimitiveAttribute(), toValidate.getDoublePrimitiveAttribute()); assertEquals(base.getLongPrimitiveAttribute(), toValidate.getLongPrimitiveAttribute()); assertEquals(base.isBooleanPrimitiveAttribute(), toValidate.isBooleanPrimitiveAttribute()); assertEquals(base.getAddressInfo().getAddress(), toValidate.getAddressInfo().getAddress()); assertEquals(base.getAddressInfo().getNumber(), toValidate.getAddressInfo().getNumber()); assertEquals(base.getAddressInfo().getCity(), toValidate.getAddressInfo().getCity()); assertEquals(base.getAddressInfo().getCityCode(), toValidate.getAddressInfo().getCityCode()); assertEquals(base.getAddressInfo().getCountry(), toValidate.getAddressInfo().getCountry()); assertEquals(base.getFloatAttribute(), toValidate.getFloatAttribute()); assertEquals(base.getFloatPrimitiveAttribute(), toValidate.getFloatPrimitiveAttribute()); assertEquals(base.getUnitFamily(), toValidate.getUnitFamily()); assertEquals(base.getBigDecimalAttribute(), toValidate.getBigDecimalAttribute()); assertEquals(base.getShortAttribute(), toValidate.getShortAttribute()); assertEquals(base.getShortPrimitiveAttribute(), toValidate.getShortPrimitiveAttribute()); // TODO add new validation below }