java.util.Date.getTimezoneOffset()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(256)

本文整理了Java中java.util.Date.getTimezoneOffset()方法的一些代码示例,展示了Date.getTimezoneOffset()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Date.getTimezoneOffset()方法的具体详情如下:
包路径:java.util.Date
类名称:Date
方法名:getTimezoneOffset

Date.getTimezoneOffset介绍

[英]Returns the timezone offset in minutes of the default TimeZone.
[中]

代码示例

代码示例来源:origin: com.alibaba/fastjson

@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);
  }
}

代码示例来源:origin: com.google.gwt/gwt-servlet

/**
 * 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;
 }
}

代码示例来源:origin: com.google.gwt/gwt-servlet

int offset = date.getTimezoneOffset();
date.setTime(date.getTime() + (this.tzOffset - offset) * 60 * 1000);

代码示例来源:origin: org.jbpm/jbpm-console-ng-generic-client

/**
 * Returns the timezone offset for the specified Date.
 */
@SuppressWarnings("deprecation")
public static final long timezoneOffsetMillis(Date date) {
  return date.getTimezoneOffset()*60*1000;
}

代码示例来源:origin: dankurka/gwtphonegap

@SuppressWarnings("deprecation")
@Override
public int getUtc_offset() {
  Date d = new Date();
  return d.getTimezoneOffset();
}

代码示例来源:origin: dankurka/gwtphonegap

@SuppressWarnings("deprecation")
@Override
public int getUtc_offset() {
  Date d = new Date();
  return d.getTimezoneOffset();
}

代码示例来源:origin: com.vaadin/vaadin-charts-flow

/**
 * @deprecated as of 4.0. Use {@link #toHighchartsTS(Instant)}
 */
@Deprecated
public static long toHighchartsTS(Date date) {
  return date.getTime() - date.getTimezoneOffset() * 60000;
}

代码示例来源:origin: stackoverflow.com

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);

代码示例来源:origin: stackoverflow.com

long ts = myObject.getDate().getTime() - myObject.getDate().getTimezoneOffset()*60000L;
Date myDate = new Date(ts - ts % (3600000L*24L));
myDate.setTime(myDate.getTime() + myDate.getTimezoneOffset()*60000L);

代码示例来源:origin: net.wetheinter/gwt-user

/**
 * 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;
 }
}

代码示例来源:origin: com.vaadin.external.gwt/gwt-user

/**
 * 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;
 }
}

代码示例来源:origin: org.jresearch.gwtproject.i18n/gwt-datetimeformat

/**
 * 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;
 }
}

代码示例来源:origin: stackoverflow.com

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());   
 }

代码示例来源:origin: jboss-fuse/fabric8

@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);
}

代码示例来源:origin: org.kie.workbench.widgets/kie-wb-common-ui

static int getClientOffset(final Date date) {
  final int standardOffset = getTimeZone().getStandardOffset();
  final int timezoneOffset = date.getTimezoneOffset();
  final int timeZoneOffsetInMinutes = standardOffset - (timezoneOffset * 2);
  return -timeZoneOffsetInMinutes;
}

代码示例来源:origin: EvoSuite/evosuite

@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;
  }
}

代码示例来源:origin: io.fabric8.insight/insight-elasticsearch

@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);
}

代码示例来源:origin: io.fabric8.insight/insight-elasticsearch-factory

@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);
}

代码示例来源:origin: keeps/roda

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());
 }
}

代码示例来源:origin: samtools/htsjdk

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());
  }
}

相关文章