@Subscribe public void onScriptCallbackEvent(ScriptCallbackEvent event) { if (!event.getEventName().equals("addTimestamp")) { return; } int[] intStack = client.getIntStack(); int intStackSize = client.getIntStackSize(); String[] stringStack = client.getStringStack(); int stringStackSize = client.getStringStackSize(); int messageId = intStack[intStackSize - 1]; MessageNode messageNode = (MessageNode) client.getMessages().get(messageId); final ZonedDateTime time = ZonedDateTime.ofInstant( Instant.ofEpochSecond(messageNode.getTimestamp()), ZoneId.systemDefault()); final String dateFormat = time.get(ChronoField.HOUR_OF_DAY) + ":" + String.format("%02d", time.get(ChronoField.MINUTE_OF_HOUR)); String timestamp = "[" + dateFormat + "] "; Color timestampColour = getTimestampColour(); if (timestampColour != null) { timestamp = ColorUtil.wrapWithColorTag(timestamp, timestampColour); } stringStack[stringStackSize - 1] = timestamp; }
@Deprecated public int getYearOfEra() { logDeprecatedMethod("getYearOfEra()", "get(ChronoField.YEAR_OF_ERA)"); return dt.get(ChronoField.YEAR_OF_ERA); }
@Deprecated public int getEra() { logDeprecatedMethod("getEra()", "get(ChronoField.ERA)"); return dt.get(ChronoField.ERA); }
@Deprecated public int getMillisOfDay() { logDeprecatedMethod("getMillisOfDay()", "get(ChronoField.MILLI_OF_DAY)"); return dt.get(ChronoField.MILLI_OF_DAY); }
@Deprecated public int getYearOfCentury() { logDeprecatedMethod("getYearOfCentury()", "get(ChronoField.YEAR_OF_ERA) % 100"); return dt.get(ChronoField.YEAR_OF_ERA) % 100; }
@Deprecated public int getMinuteOfDay() { logDeprecatedMethod("getMinuteOfDay()", "get(ChronoField.MINUTE_OF_DAY)"); return dt.get(ChronoField.MINUTE_OF_DAY); }
@Deprecated public int getCenturyOfEra() { logDeprecatedMethod("getCenturyOfEra()", "get(ChronoField.YEAR_OF_ERA) / 100"); return dt.get(ChronoField.YEAR_OF_ERA) / 100; }
@Deprecated public int getMillisOfSecond() { logDeprecatedMethod("getMillisOfSecond()", "get(ChronoField.MILLI_OF_SECOND)"); return dt.get(ChronoField.MILLI_OF_SECOND); }
@Deprecated public int getSecondOfDay() { logDeprecatedMethod("getSecondOfDay()", "get(ChronoField.SECOND_OF_DAY)"); return dt.get(ChronoField.SECOND_OF_DAY); }
@Deprecated public int getWeekOfWeekyear() { logDeprecatedMethod("getWeekOfWeekyear()", "get(WeekFields.ISO.weekOfWeekBasedYear())"); return dt.get(WeekFields.ISO.weekOfWeekBasedYear()); }
@Deprecated public int getWeekyear() { logDeprecatedMethod("getWeekyear()", "get(WeekFields.ISO.weekBasedYear())"); return dt.get(WeekFields.ISO.weekBasedYear()); }
@UserFunction @Description("apoc.date.field(12345,('ms|s|m|h|d|month|year'),('TZ')") public Long field(final @Name("time") Long time, @Name(value = "unit", defaultValue = "d") String unit, @Name(value = "timezone",defaultValue = "UTC") String timezone) { return (time == null) ? null : (long) ZonedDateTime .ofInstant( Instant.ofEpochMilli( time ), ZoneId.of( timezone ) ) .get( chronoField( unit ) ); }
public static int getCurrentTimeInBeats() { ZonedDateTime now = ZonedDateTime.now( ZoneId.of( "UTC+01:00" ) ); // "Biel Meantime" = UTC+01:00 int beats = (int) ( ( now.get( ChronoField.SECOND_OF_MINUTE) + ( now.get( ChronoField.MINUTE_OF_HOUR ) * 60 ) + ( now.get( ChronoField.HOUR_OF_DAY) * 3600 ) ) / 86.4 ); return beats; }
ZoneId zoneId = ZoneId.of ( "America/Montreal" ); ZonedDateTime now = ZonedDateTime.now ( zoneId ); int weekOfYear = now.get ( IsoFields.WEEK_OF_WEEK_BASED_YEAR ); int weekBasedYear = now.get ( IsoFields.WEEK_BASED_YEAR ); System.out.println ( "weekOfYear: " + weekOfYear + " of weekBasedYear: " + weekBasedYear );
ZoneId zoneId = ZoneId.of( "America/Montreal" ); LocalDate twelves = LocalDate.of( 2012 , 12 , 12 ); ZonedDateTime twelvesMontreal = twelves.atStartOfDay( zoneId ); int week = twelvesMontreal.get ( IsoFields.WEEK_OF_WEEK_BASED_YEAR ); int weekYear = twelvesMontreal.get ( IsoFields.WEEK_BASED_YEAR );
@Deprecated public int getMillisOfDay() { logDeprecatedMethod("getMillisOfDay()", "get(ChronoField.MILLI_OF_DAY)"); return dt.get(ChronoField.MILLI_OF_DAY); }
@Deprecated public int getMinuteOfDay() { logDeprecatedMethod("getMinuteOfDay()", "get(ChronoField.MINUTE_OF_DAY)"); return dt.get(ChronoField.MINUTE_OF_DAY); }
@Deprecated public int getYearOfEra() { logDeprecatedMethod("getYearOfEra()", "get(ChronoField.YEAR_OF_ERA)"); return dt.get(ChronoField.YEAR_OF_ERA); }
@Deprecated public int getCenturyOfEra() { logDeprecatedMethod("getCenturyOfEra()", "get(ChronoField.YEAR_OF_ERA) / 100"); return dt.get(ChronoField.YEAR_OF_ERA) / 100; }
@Deprecated public int getEra() { logDeprecatedMethod("getEra()", "get(ChronoField.ERA)"); return dt.get(ChronoField.ERA); }