@SuppressWarnings("deprecation") public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException { if (object == null) { serializer.out.writeNull(); return; } Date date = (Date) object; JSONObject json = new JSONObject(); json.put("date", date.getDate()); json.put("day", date.getDay()); json.put("hours", date.getHours()); json.put("minutes", date.getMinutes()); json.put("month", date.getMonth()); json.put("seconds", date.getSeconds()); json.put("time", date.getTime()); json.put("timezoneOffset", date.getTimezoneOffset()); json.put("year", date.getYear()); serializer.write(json); } }
/** * Class PatternPart holds a "compiled" pattern part. */ private static class PatternPart { public String text; public int count; // 0 has a special meaning, it stands for literal public boolean abutStart; public PatternPart(String txt, int cnt) { text = txt; count = cnt; abutStart = false; } }
int offset = date.getTimezoneOffset(); date.setTime(date.getTime() + (this.tzOffset - offset) * 60 * 1000);
/** * Returns the timezone offset for the specified Date. */ @SuppressWarnings("deprecation") public static final long timezoneOffsetMillis(Date date) { return date.getTimezoneOffset()*60*1000; }
@SuppressWarnings("deprecation") @Override public int getUtc_offset() { Date d = new Date(); return d.getTimezoneOffset(); }
@SuppressWarnings("deprecation") @Override public int getUtc_offset() { Date d = new Date(); return d.getTimezoneOffset(); }
/** * @deprecated as of 4.0. Use {@link #toHighchartsTS(Instant)} */ @Deprecated public static long toHighchartsTS(Date date) { return date.getTime() - date.getTimezoneOffset() * 60000; }
final long MILLIS_IN_MINUTE = 60000; Date localDate = DateTimeFormat.getFormat("dd MMM yyyy HH:mm:ss").parse(dateString); int localOffset = localDate.getTimezoneOffset() * MILLIS_IN_MINUTE; int targetOffset = tz.getOffset(localDate) * MILLIS_IN_MINUTE; // Subtract the offset to make this into a UTC date. return new Date(localDate.getTime() - localOffset + targetOffset);
long ts = myObject.getDate().getTime() - myObject.getDate().getTimezoneOffset()*60000L; Date myDate = new Date(ts - ts % (3600000L*24L)); myDate.setTime(myDate.getTime() + myDate.getTimezoneOffset()*60000L);
/** * Class PatternPart holds a "compiled" pattern part. */ private static class PatternPart { public String text; public int count; // 0 has a special meaning, it stands for literal public boolean abutStart; public PatternPart(String txt, int cnt) { text = txt; count = cnt; abutStart = false; } }
/** * Class PatternPart holds a "compiled" pattern part. */ private static class PatternPart { public String text; public int count; // 0 has a special meaning, it stands for literal public boolean abutStart; public PatternPart(String txt, int cnt) { text = txt; count = cnt; abutStart = false; } }
/** * Class PatternPart holds a "compiled" pattern part. */ private static class PatternPart { public String text; public int count; // 0 has a special meaning, it stands for literal public boolean abutStart; public PatternPart(String txt, int cnt) { text = txt; count = cnt; abutStart = false; } }
public static void main(String[] args) { Time time = new Time(00,00,00); Time time2 = new Time(02,00,00); long longTime = (time2.getTime() - time.getTime()); Time finalTime = new Time(longTime); int timeOffset = time.getTimezoneOffset(); finalTime.setMinutes(finalTime.getMinutes()+timeOffset); System.out.println(finalTime.toString()); }
@Override public void store(String type, long timestamp, String jsonData) { Date ts = new Date(timestamp); Date utc = new Date(ts.getTime() + ts.getTimezoneOffset() * 60000); IndexRequest ir = new IndexRequest() .index("insight-"+ indexFormat.format(utc)) .type(type) .source(jsonData) .create(true); queue.add(ir); }
static int getClientOffset(final Date date) { final int standardOffset = getTimeZone().getStandardOffset(); final int timezoneOffset = date.getTimezoneOffset(); final int timeZoneOffsetInMinutes = standardOffset - (timezoneOffset * 2); return -timeZoneOffsetInMinutes; }
@SuppressWarnings("deprecation") public int getTimezoneOffset() { Capturer.capture(Instrumenter.CAPTURE_ID_JAVA_UTIL_DATE, this, "getTimezoneOffset", "()I", new Object[] {}); int ret = super.getTimezoneOffset(); Capturer.enable(Instrumenter.CAPTURE_ID_JAVA_UTIL_DATE, this, ret); return ret; } }
@Override public void store(String type, long timestamp, String jsonData) { Date ts = new Date(timestamp); Date utc = new Date(ts.getTime() + ts.getTimezoneOffset() * 60000); IndexRequest ir = new IndexRequest() .index("insight-"+ indexFormat.format(utc)) .type(type) .source(jsonData) .create(true); queue.add(ir); }
@Override public void store(String type, long timestamp, String jsonData) { Date ts = new Date(timestamp); Date utc = new Date(ts.getTime() + ts.getTimezoneOffset() * 60000); IndexRequest ir = new IndexRequest() .index("insight-"+ indexFormat.format(utc)) .type(type) .source(jsonData) .create(true); queue.add(ir); }
public DateIntervalFilterParameter(String fromName, String toName, Date fromValue, Date toValue) { setFromName(fromName); setToName(toName); setFromValue(fromValue); setToValue(toValue); if (toValue != null) { setTimeZoneOffset(toValue.getTimezoneOffset()); } else if (fromValue != null) { this.setTimeZoneOffset(fromValue.getTimezoneOffset()); } }
public static void assertDatesAreClose(final Date lhs, final Date rhs) { Assert.assertEquals(lhs.getYear(), rhs.getYear()); Assert.assertEquals(lhs.getMonth(), rhs.getMonth()); Assert.assertEquals(lhs.getDate(), rhs.getDate()); Assert.assertEquals(lhs.getDay(), rhs.getDay()); Assert.assertEquals(lhs.getHours(), rhs.getHours()); Assert.assertEquals(lhs.getMinutes(), rhs.getMinutes()); Assert.assertEquals(lhs.getSeconds(), rhs.getSeconds()); Assert.assertEquals(lhs.getTimezoneOffset(), rhs.getTimezoneOffset()); } }