Java Code Examples for java.time.LocalDateTime#getDayOfMonth()
The following examples show how to use
java.time.LocalDateTime#getDayOfMonth() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FakeUtils.java From sailfish-core with Apache License 2.0 | 6 votes |
@UtilityMethod public final String ExpireDate(String dateFormat) { // 2011.09.16 DG: Return String as soon as tag ExpireDate defined as String in QFJ. LocalDateTime localDateTime = DateUtil.modifyLocalDateTime(dateFormat); int year = localDateTime.getYear(); int month = localDateTime.getMonth().getValue(); int day = localDateTime.getDayOfMonth(); StringBuilder sb = new StringBuilder(); sb.append(year); if(month < 10) { sb.append(0); } sb.append(month); if(day < 10) { sb.append(0); } sb.append(day); return sb.toString(); }
Example 2
Source File: ZipUtils.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Converts Java time to DOS time. */ private static long javaToDosTime(long time) { Instant instant = Instant.ofEpochMilli(time); LocalDateTime ldt = LocalDateTime.ofInstant( instant, ZoneId.systemDefault()); int year = ldt.getYear() - 1980; if (year < 0) { return (1 << 21) | (1 << 16); } return (year << 25 | ldt.getMonthValue() << 21 | ldt.getDayOfMonth() << 16 | ldt.getHour() << 11 | ldt.getMinute() << 5 | ldt.getSecond() >> 1) & 0xffffffffL; }
Example 3
Source File: ZipUtils.java From Bytecoder with Apache License 2.0 | 6 votes |
/** * Converts Java time to DOS time. */ private static long javaToDosTime(long time) { Instant instant = Instant.ofEpochMilli(time); LocalDateTime ldt = LocalDateTime.ofInstant( instant, ZoneId.systemDefault()); int year = ldt.getYear() - 1980; if (year < 0) { return (1 << 21) | (1 << 16); } return (year << 25 | ldt.getMonthValue() << 21 | ldt.getDayOfMonth() << 16 | ldt.getHour() << 11 | ldt.getMinute() << 5 | ldt.getSecond() >> 1) & 0xffffffffL; }
Example 4
Source File: DefaultOrderNumberGeneratorImpl.java From yes-cart with Apache License 2.0 | 5 votes |
String datePart(final LocalDateTime dateTime) { final long year = dateTime.getYear(); final long mth = dateTime.getMonthValue(); final long day = dateTime.getDayOfMonth(); final long hour = dateTime.getHour(); final long min = dateTime.getMinute(); final long sec = dateTime.getSecond(); final long time = (year % 100) * 10000000000L + mth * 100000000L + day * 1000000L + hour * 10000L + min * 100 + sec; return String.valueOf(time); }
Example 5
Source File: ZipUtils.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public static long javaToDosTime(long time) { Instant instant = Instant.ofEpochMilli(time); LocalDateTime ldt = LocalDateTime.ofInstant( instant, ZoneId.systemDefault()); int year = ldt.getYear() - 1980; if (year < 0) { return (1 << 21) | (1 << 16); } return (year << 25 | ldt.getMonthValue() << 21 | ldt.getDayOfMonth() << 16 | ldt.getHour() << 11 | ldt.getMinute() << 5 | ldt.getSecond() >> 1) & 0xffffffffL; }
Example 6
Source File: FrmSectionPlot.java From MeteoInfo with GNU Lesser General Public License v3.0 | 5 votes |
private List<String> getTimeGridStr() { List<String> GStrList = new ArrayList<>(); int i; DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); List<LocalDateTime> DTList = new ArrayList<>(); for (i = 0; i < this.jComboBox_Time1.getItemCount(); i++) { DTList.add(LocalDateTime.parse(this.jComboBox_Time1.getItemAt(i).toString(), dateFormat)); } String timeFormat; Duration duration = Duration.between(DTList.get(0), DTList.get(1)); if (duration.getSeconds() < 3600) { timeFormat = "yyyy-MM-dd HH:mm"; } else if (duration.toHours() < 24) { timeFormat = "yyyy-MM-dd HH"; } else { timeFormat = "yyyy-MM-dd"; } LocalDateTime ldt = DTList.get(0); int sYear = ldt.getYear(); int sMonth = ldt.getDayOfMonth(); ldt = DTList.get(DTList.size() - 1); int eYear = ldt.getYear(); int eMonth = ldt.getDayOfMonth(); if (sYear == eYear) { timeFormat = timeFormat.substring(5); if (sMonth == eMonth) { timeFormat = timeFormat.substring(3); } } DateTimeFormatter dataFormat = DateTimeFormatter.ofPattern(timeFormat); for (i = 0; i < DTList.size(); i++) { GStrList.add(dataFormat.format(DTList.get(i))); } return GStrList; }
Example 7
Source File: WinterPricePolicy.java From microservice_coffeeshop with Apache License 2.0 | 5 votes |
@Override public boolean seasonMatch() { LocalDateTime localDateTime = LocalDateTime.now(); if (3 <= localDateTime.getDayOfMonth() && localDateTime.getDayOfMonth() <= 9) { return false; } return true; }
Example 8
Source File: DataTypeCodec.java From vertx-sql-client with Apache License 2.0 | 5 votes |
private static void binaryEncodeDatetime(LocalDateTime value, ByteBuf buffer) { int year = value.getYear(); int month = value.getMonthValue(); int day = value.getDayOfMonth(); int hour = value.getHour(); int minute = value.getMinute(); int second = value.getSecond(); int microsecond = value.getNano() / 1000; // LocalDateTime does not have a zero value of month or day if (hour == 0 && minute == 0 && second == 0 && microsecond == 0) { buffer.writeByte(4); buffer.writeShortLE(year); buffer.writeByte(month); buffer.writeByte(day); } else if (microsecond == 0) { buffer.writeByte(7); buffer.writeShortLE(year); buffer.writeByte(month); buffer.writeByte(day); buffer.writeByte(hour); buffer.writeByte(minute); buffer.writeByte(second); } else { buffer.writeByte(11); buffer.writeShortLE(year); buffer.writeByte(month); buffer.writeByte(day); buffer.writeByte(hour); buffer.writeByte(minute); buffer.writeByte(second); buffer.writeIntLE(microsecond); } }
Example 9
Source File: TitleDisplay.java From minicraft-plus-revived with GNU General Public License v3.0 | 5 votes |
@Override public void init(Display parent) { super.init(null); // The TitleScreen never has a parent. Renderer.readyToRenderGameplay = false; // check version checkVersion(); /// this is useful to just ensure that everything is really reset as it should be. if (Game.server != null) { if (Game.debug) System.out.println("wrapping up loose server ends"); Game.server.endConnection(); Game.server = null; } if (Game.client != null) { if (Game.debug) System.out.println("wrapping up loose client ends"); Game.client.endConnection(); Game.client = null; } Game.ISONLINE = false; LocalDateTime time = LocalDateTime.now(); if (time.getMonth() == Month.DECEMBER) { if (time.getDayOfMonth() == 19) rand = 1; if (time.getDayOfMonth() == 25) rand = 2; } else { rand = random.nextInt(splashes.length - 3) + 3; } World.levels = new Level[World.levels.length]; if(Game.player == null || Game.player instanceof RemotePlayer) // was online, need to reset player World.resetGame(false); }
Example 10
Source File: DateMilliAccessor.java From dremio-oss with Apache License 2.0 | 5 votes |
private Date getDate(int index, TimeZone tz) { if (ac.isNull(index)) { return null; } // The Arrow datetime values are already in UTC, so adjust to the timezone of the calendar passed in to // ensure the reported value is correct according to the JDBC spec. final LocalDateTime date = LocalDateTime.ofInstant(Instant.ofEpochMilli(ac.get(index)), tz.toZoneId()); return new Date(date.getYear() - 1900, date.getMonthValue() - 1, date.getDayOfMonth()); }
Example 11
Source File: BotLogger.java From TelegramApi with MIT License | 5 votes |
private static String dateFormatterForLogs(@NotNull LocalDateTime dateTime) { String dateString = "["; dateString += dateTime.getDayOfMonth() + "_"; dateString += dateTime.getMonthValue() + "_"; dateString += dateTime.getYear() + "_"; dateString += dateTime.getHour() + ":"; dateString += dateTime.getMinute() + ":"; dateString += dateTime.getSecond(); dateString += "] "; return dateString; }
Example 12
Source File: CongratsTest.java From vertx-in-action with MIT License | 5 votes |
private KafkaProducerRecord<String, JsonObject> record(String deviceId, long steps) { LocalDateTime now = LocalDateTime.now(); String key = deviceId + ":" + now.getYear() + "-" + now.getMonth() + "-" + now.getDayOfMonth(); JsonObject json = new JsonObject() .put("deviceId", deviceId) .put("timestamp", now.toString()) .put("stepsCount", steps); return KafkaProducerRecord.create("daily.step.updates", key, json); }
Example 13
Source File: EventStatsTest.java From vertx-in-action with MIT License | 5 votes |
private KafkaProducerRecord<String, JsonObject> dailyStepsUpdateRecord(String deviceId, long steps) { LocalDateTime now = LocalDateTime.now(); String key = deviceId + ":" + now.getYear() + "-" + now.getMonth() + "-" + now.getDayOfMonth(); JsonObject json = new JsonObject() .put("deviceId", deviceId) .put("timestamp", now.toString()) .put("stepsCount", steps); return KafkaProducerRecord.create("daily.step.updates", key, json); }
Example 14
Source File: EventStatsTest.java From vertx-in-action with MIT License | 5 votes |
private KafkaProducerRecord<String, JsonObject> incomingStepsRecord(String deviceId, long syncId, long steps) { LocalDateTime now = LocalDateTime.now(); String key = deviceId + ":" + now.getYear() + "-" + now.getMonth() + "-" + now.getDayOfMonth(); JsonObject json = new JsonObject() .put("deviceId", deviceId) .put("syncId", syncId) .put("stepsCount", steps); return KafkaProducerRecord.create("incoming.steps", key, json); }
Example 15
Source File: DateTime.java From Algorithms-and-Data-Structures-in-Java with GNU General Public License v3.0 | 4 votes |
private static String addTwoDays() { LocalDateTime now = LocalDateTime.ofInstant(Instant.now(), ZoneId.of("UTC")); LocalDateTime afterTwoDays = now.plusDays(2); return afterTwoDays.getDayOfMonth() + "-" + afterTwoDays.getMonthValue() + "-" + afterTwoDays.getYear(); }
Example 16
Source File: Timestamp.java From openjdk-8-source with GNU General Public License v2.0 | 3 votes |
/** * Obtains an instance of {@code Timestamp} from a {@code LocalDateTime} * object, with the same year, month, day of month, hours, minutes, * seconds and nanos date-time value as the provided {@code LocalDateTime}. * <p> * The provided {@code LocalDateTime} is interpreted as the local * date-time in the local time zone. * * @param dateTime a {@code LocalDateTime} to convert * @return a {@code Timestamp} object * @exception NullPointerException if {@code dateTime} is null. * @since 1.8 */ @SuppressWarnings("deprecation") public static Timestamp valueOf(LocalDateTime dateTime) { return new Timestamp(dateTime.getYear() - 1900, dateTime.getMonthValue() - 1, dateTime.getDayOfMonth(), dateTime.getHour(), dateTime.getMinute(), dateTime.getSecond(), dateTime.getNano()); }
Example 17
Source File: Timestamp.java From dragonwell8_jdk with GNU General Public License v2.0 | 3 votes |
/** * Obtains an instance of {@code Timestamp} from a {@code LocalDateTime} * object, with the same year, month, day of month, hours, minutes, * seconds and nanos date-time value as the provided {@code LocalDateTime}. * <p> * The provided {@code LocalDateTime} is interpreted as the local * date-time in the local time zone. * * @param dateTime a {@code LocalDateTime} to convert * @return a {@code Timestamp} object * @exception NullPointerException if {@code dateTime} is null. * @since 1.8 */ @SuppressWarnings("deprecation") public static Timestamp valueOf(LocalDateTime dateTime) { return new Timestamp(dateTime.getYear() - 1900, dateTime.getMonthValue() - 1, dateTime.getDayOfMonth(), dateTime.getHour(), dateTime.getMinute(), dateTime.getSecond(), dateTime.getNano()); }
Example 18
Source File: Timestamp.java From openjdk-jdk8u with GNU General Public License v2.0 | 3 votes |
/** * Obtains an instance of {@code Timestamp} from a {@code LocalDateTime} * object, with the same year, month, day of month, hours, minutes, * seconds and nanos date-time value as the provided {@code LocalDateTime}. * <p> * The provided {@code LocalDateTime} is interpreted as the local * date-time in the local time zone. * * @param dateTime a {@code LocalDateTime} to convert * @return a {@code Timestamp} object * @exception NullPointerException if {@code dateTime} is null. * @since 1.8 */ @SuppressWarnings("deprecation") public static Timestamp valueOf(LocalDateTime dateTime) { return new Timestamp(dateTime.getYear() - 1900, dateTime.getMonthValue() - 1, dateTime.getDayOfMonth(), dateTime.getHour(), dateTime.getMinute(), dateTime.getSecond(), dateTime.getNano()); }
Example 19
Source File: Timestamp.java From jdk1.8-source-analysis with Apache License 2.0 | 3 votes |
/** * Obtains an instance of {@code Timestamp} from a {@code LocalDateTime} * object, with the same year, month, day of month, hours, minutes, * seconds and nanos date-time value as the provided {@code LocalDateTime}. * <p> * The provided {@code LocalDateTime} is interpreted as the local * date-time in the local time zone. * * @param dateTime a {@code LocalDateTime} to convert * @return a {@code Timestamp} object * @exception NullPointerException if {@code dateTime} is null. * @since 1.8 */ @SuppressWarnings("deprecation") public static Timestamp valueOf(LocalDateTime dateTime) { return new Timestamp(dateTime.getYear() - 1900, dateTime.getMonthValue() - 1, dateTime.getDayOfMonth(), dateTime.getHour(), dateTime.getMinute(), dateTime.getSecond(), dateTime.getNano()); }
Example 20
Source File: Timestamp.java From jdk8u-jdk with GNU General Public License v2.0 | 3 votes |
/** * Obtains an instance of {@code Timestamp} from a {@code LocalDateTime} * object, with the same year, month, day of month, hours, minutes, * seconds and nanos date-time value as the provided {@code LocalDateTime}. * <p> * The provided {@code LocalDateTime} is interpreted as the local * date-time in the local time zone. * * @param dateTime a {@code LocalDateTime} to convert * @return a {@code Timestamp} object * @exception NullPointerException if {@code dateTime} is null. * @since 1.8 */ @SuppressWarnings("deprecation") public static Timestamp valueOf(LocalDateTime dateTime) { return new Timestamp(dateTime.getYear() - 1900, dateTime.getMonthValue() - 1, dateTime.getDayOfMonth(), dateTime.getHour(), dateTime.getMinute(), dateTime.getSecond(), dateTime.getNano()); }