gpt4 book ai didi

org.eclipse.persistence.internal.oxm.XMLConversionManager.getTimeZone()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-19 12:06:40 26 4
gpt4 key购买 nike

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

XMLConversionManager.getTimeZone介绍

[英]Return the specified TimeZone used for all String to date object conversions.
[中]返回用于所有字符串到日期对象转换的指定时区。

代码示例

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

private String appendTimeZone(String string, Date date) {
  StringBuilder stringBuilder = new StringBuilder(string);
  // GMT Time Zone
  int rawMinuteOffset = getTimeZone().getOffset(date.getTime()) / 60000;
  if (0 == rawMinuteOffset) {
    stringBuilder.append(GMT_SUFFIX);
    return stringBuilder.toString();
  }
  // +HH:MM
  if (rawMinuteOffset < 0) {
    stringBuilder.append('-');
    rawMinuteOffset = Math.abs(rawMinuteOffset);
  } else {
    stringBuilder.append('+');
  }
  int hourOffset = rawMinuteOffset / 60;
  if (hourOffset < 10) {
    stringBuilder.append('0');
  }
  stringBuilder.append(hourOffset);
  stringBuilder.append(Constants.COLON);
  int minuteOffset = rawMinuteOffset % 60;
  if (minuteOffset < 10) {
    stringBuilder.append('0');
  }
  stringBuilder.append(minuteOffset);
  return stringBuilder.toString();
}

代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

public Calendar convertStringToCalendar(String sourceString, QName schemaTypeQName) {
  java.util.Date date = convertStringToDate(sourceString, schemaTypeQName);
  Calendar cal = Helper.calendarFromUtilDate(date);
  cal.setTimeZone(getTimeZone());
  return cal;
}

代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

int rawMinuteOffset = getTimeZone().getRawOffset() / 60000;
if (0 == rawMinuteOffset) {
  stringBuilder.append(GMT_SUFFIX);

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core

private String appendTimeZone(String string, Date date) {
  StringBuilder stringBuilder = new StringBuilder(string);
  // GMT Time Zone
  int rawMinuteOffset = getTimeZone().getOffset(date.getTime()) / 60000;
  if (0 == rawMinuteOffset) {
    stringBuilder.append(GMT_SUFFIX);
    return stringBuilder.toString();
  }
  // +HH:MM
  if (rawMinuteOffset < 0) {
    stringBuilder.append('-');
    rawMinuteOffset = Math.abs(rawMinuteOffset);
  } else {
    stringBuilder.append('+');
  }
  int hourOffset = rawMinuteOffset / 60;
  if (hourOffset < 10) {
    stringBuilder.append('0');
  }
  stringBuilder.append(hourOffset);
  stringBuilder.append(Constants.COLON);
  int minuteOffset = rawMinuteOffset % 60;
  if (minuteOffset < 10) {
    stringBuilder.append('0');
  }
  stringBuilder.append(minuteOffset);
  return stringBuilder.toString();
}

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core

private String stringFromSQLTime(Time sourceTime) {
  XMLGregorianCalendar xgc = getDatatypeFactory().newXMLGregorianCalendar();
  Calendar cal = Calendar.getInstance(getTimeZone());
  cal.setTime(sourceTime);
  xgc.setHour(cal.get(Calendar.HOUR_OF_DAY));
  xgc.setMinute(cal.get(Calendar.MINUTE));
  xgc.setSecond(cal.get(Calendar.SECOND));
  String string= xgc.toXMLFormat();
  string = appendMillis(string, sourceTime.getTime());
  return appendTimeZone(string, sourceTime);
}

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core

/**
 * This method returns a dateTime string representing a given
 * java.util.Date.
 *
 * BC dates (sourceDate.getTime() < YEAR_ONE_AD_TIME) are handled
 * as follows: '2007 BC' --> '-2006 AD'
 *
 * @param sourceDate
 * @return
 */
private String stringFromDate(java.util.Date sourceDate) {
  GregorianCalendar cal = new GregorianCalendar(getTimeZone());
  cal.setTime(sourceDate);
  XMLGregorianCalendar xgc = getDatatypeFactory().newXMLGregorianCalendar(cal);
  String string =  xgc.toXMLFormat();
  string = truncateMillis(string);
  return string;
}

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core

private String stringFromSQLDate(java.sql.Date sourceDate) {
  XMLGregorianCalendar xgc = getDatatypeFactory().newXMLGregorianCalendar();
  Calendar cal = Calendar.getInstance(getTimeZone());
  cal.setTime(sourceDate);
  if(cal.get(Calendar.ERA) == GregorianCalendar.BC){
    xgc.setYear(-cal.get(Calendar.YEAR));
  }else{
    xgc.setYear(cal.get(Calendar.YEAR));
  }
  xgc.setMonth(cal.get(Calendar.MONTH)+1);
  xgc.setDay(cal.get(Calendar.DAY_OF_MONTH));
  return xgc.toXMLFormat();
}

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

private String stringFromSQLTime(Time sourceTime) {
  XMLGregorianCalendar xgc = getDatatypeFactory().newXMLGregorianCalendar();
  GregorianCalendar cal = new GregorianCalendar(getTimeZone());
  cal.setGregorianChange(new Date(Long.MIN_VALUE));
  cal.setTime(sourceTime);
  xgc.setHour(cal.get(Calendar.HOUR_OF_DAY));
  xgc.setMinute(cal.get(Calendar.MINUTE));
  xgc.setSecond(cal.get(Calendar.SECOND));
  String string= xgc.toXMLFormat();
  string = appendMillis(string, sourceTime.getTime());
  return appendTimeZone(string, sourceTime);
}

代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

public java.util.Date convertStringToDate(String sourceString, QName schemaType) {
  XMLGregorianCalendar xmlGregorianCalender = convertStringToXMLGregorianCalendar(sourceString, schemaType);
  if (schemaType == null) {
    schemaType = xmlGregorianCalender.getXMLSchemaType();
  }
  XMLGregorianCalendar defaults = getDatatypeFactory().newXMLGregorianCalendar();
  defaults.setTimezone(getTimeZone().getRawOffset()/60000);
  GregorianCalendar cal;
  if(xmlGregorianCalender.getTimezone() == DatatypeConstants.FIELD_UNDEFINED){
    cal = xmlGregorianCalender.toGregorianCalendar(getTimeZone(), null, null);
  }else{
    cal = xmlGregorianCalender.toGregorianCalendar();
  }
  cal.setGregorianChange(new Date(Long.MAX_VALUE));
  Date returnDate= cal.getTime();
  return returnDate;
}

代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

private String stringFromSQLTime(Time sourceTime) {
  XMLGregorianCalendar xgc = getDatatypeFactory().newXMLGregorianCalendar();
  GregorianCalendar cal = new GregorianCalendar(getTimeZone());
  cal.setGregorianChange(new Date(Long.MIN_VALUE));
  cal.setTime(sourceTime);
  xgc.setHour(cal.get(Calendar.HOUR_OF_DAY));
  xgc.setMinute(cal.get(Calendar.MINUTE));
  xgc.setSecond(cal.get(Calendar.SECOND));
  String string= xgc.toXMLFormat();
  return appendTimeZone(string);
}

代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

private String stringFromSQLDate(java.sql.Date sourceDate) {
  XMLGregorianCalendar xgc = getDatatypeFactory().newXMLGregorianCalendar();
  GregorianCalendar cal = new GregorianCalendar(getTimeZone());
  cal.setGregorianChange(new Date(Long.MIN_VALUE));
  cal.setTime(sourceDate);
  if(cal.get(Calendar.ERA) == GregorianCalendar.BC){
    xgc.setYear(-cal.get(Calendar.YEAR));
  }else{
    xgc.setYear(cal.get(Calendar.YEAR));
  }
  xgc.setMonth(cal.get(Calendar.MONTH)+1);
  xgc.setDay(cal.get(Calendar.DAY_OF_MONTH));
  return xgc.toXMLFormat();
}

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

private String stringFromSQLDate(java.sql.Date sourceDate) {
  XMLGregorianCalendar xgc = getDatatypeFactory().newXMLGregorianCalendar();
  GregorianCalendar cal = new GregorianCalendar(getTimeZone());
  cal.setGregorianChange(new Date(Long.MIN_VALUE));
  cal.setTime(sourceDate);
  if(cal.get(Calendar.ERA) == GregorianCalendar.BC){
    xgc.setYear(-cal.get(Calendar.YEAR));
  }else{
    xgc.setYear(cal.get(Calendar.YEAR));
  }
  xgc.setMonth(cal.get(Calendar.MONTH)+1);
  xgc.setDay(cal.get(Calendar.DAY_OF_MONTH));
  return xgc.toXMLFormat();
}

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

/**
 * This method returns a dateTime string representing a given
 * java.util.Date.
 *
 * BC dates (sourceDate.getTime() < YEAR_ONE_AD_TIME) are handled
 * as follows: '2007 BC' --> '-2006 AD'
 *
 * @param sourceDate
 * @return
 */
private String stringFromDate(java.util.Date sourceDate) {
  GregorianCalendar cal = new GregorianCalendar(getTimeZone());
  cal.setTime(sourceDate);
  XMLGregorianCalendar xgc = getDatatypeFactory().newXMLGregorianCalendar(cal);
  String string =  xgc.toXMLFormat();
  string = truncateMillis(string);
  return string;
}

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

/**
 * Convert from a Date to a String representation of the MonthDay type.
 * 
 * @param date the date to convert
 * @return a Date to a String representation of the MonthDay type.
 */
public String toMonthDay(Date date) {
  if (null == date) {
    return null;
  }
  GregorianCalendar dateCalendar = new GregorianCalendar(getXMLConversionManager().getTimeZone());
  dateCalendar.clear();
  dateCalendar.setTime(date);
  dateCalendar.clear(Calendar.ZONE_OFFSET);
  return toMonthDay(dateCalendar);
}

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.sdo

/**
 * Creates a Calendar based on a given Duration and Locale.
 *
 * @param dur the Duration object to use to populate the Calendar
 * @param loc the Locale to use - null is a valid value
 *
 * @return a Calendar
 */
private Calendar toCalendar(Duration dur, Locale loc) {
  Calendar cal;
  if (loc == null) {
    cal = Calendar.getInstance(getXMLConversionManager().getTimeZone());
  } else {
    cal = Calendar.getInstance(getXMLConversionManager().getTimeZone(), loc);
  }
  cal.setTimeInMillis(dur.getTimeInMillis(cal));
  cal.set(Calendar.YEAR, dur.getYears());
  cal.set(Calendar.MONTH, dur.getMonths() - 1);
  cal.set(Calendar.DATE, dur.getDays());
  cal.set(Calendar.HOUR_OF_DAY, dur.getHours());
  cal.set(Calendar.MINUTE, dur.getMinutes());
  cal.set(Calendar.SECOND, dur.getSeconds());
  return cal;
}

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.sdo

/**
 * Convert from a Date to a String representation of the MonthDay type.
 *
 * @param date the date to convert
 * @return a Date to a String representation of the MonthDay type.
 */
public String toMonthDay(Date date) {
  if (null == date) {
    return null;
  }
  GregorianCalendar dateCalendar = new GregorianCalendar(getXMLConversionManager().getTimeZone());
  dateCalendar.clear();
  dateCalendar.setTime(date);
  dateCalendar.clear(Calendar.ZONE_OFFSET);
  return toMonthDay(dateCalendar);
}

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

/**
 * Creates a Calendar based on a given Duration and Locale.
 * 
 * @param dur the Duration object to use to populate the Calendar
 * @param loc the Locale to use - null is a valid value
 *            
 * @return a Calendar 
 */
private Calendar toCalendar(Duration dur, Locale loc) {
  Calendar cal;
  if (loc == null) {
    cal = Calendar.getInstance(getXMLConversionManager().getTimeZone());
  } else {
    cal = Calendar.getInstance(getXMLConversionManager().getTimeZone(), loc);
  }
  cal.setTimeInMillis(dur.getTimeInMillis(cal));
  cal.set(Calendar.YEAR, dur.getYears());
  cal.set(Calendar.MONTH, dur.getMonths() - 1);
  cal.set(Calendar.DATE, dur.getDays());
  cal.set(Calendar.HOUR_OF_DAY, dur.getHours());
  cal.set(Calendar.MINUTE, dur.getMinutes());
  cal.set(Calendar.SECOND, dur.getSeconds());
  return cal;
}

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core

/**
 * This method returns a dateTime string representing a given
 * Timestamp.
 *
 * BC dates (sourceDate.getTime() < YEAR_ONE_AD_TIME) are handled
 * as follows: '2007 BC' --> '-2006 AD'
 *
 * @param sourceDate
 * @return
 */
private String stringFromTimestamp(Timestamp sourceDate) {
  Calendar cal = Calendar.getInstance(getTimeZone());
  cal.setTime(sourceDate);
  XMLGregorianCalendar xgc = getDatatypeFactory().newXMLGregorianCalendar();
  if(cal.get(Calendar.ERA)== GregorianCalendar.BC){
    xgc.setYear(-cal.get(Calendar.YEAR));
  }else{
    xgc.setYear(cal.get(Calendar.YEAR));
  }
  xgc.setMonth(cal.get(Calendar.MONTH)+1);
  xgc.setDay(cal.get(Calendar.DAY_OF_MONTH));
  xgc.setHour(cal.get(Calendar.HOUR_OF_DAY));
  xgc.setMinute(cal.get(Calendar.MINUTE));
  xgc.setSecond(cal.get(Calendar.SECOND));
  String string= xgc.toXMLFormat();
  string = appendNanos(string, sourceDate);
  return appendTimeZone(string, sourceDate);
}

代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

/**
 * This method returns a dateTime string representing a given
 * Timestamp.
 *
 * BC dates (sourceDate.getTime() < YEAR_ONE_AD_TIME) are handled
 * as follows: '2007 BC' --> '-2006 AD'
 *
 * @param sourceDate
 * @return
 */
private String stringFromTimestamp(Timestamp sourceDate) {
  GregorianCalendar cal = new GregorianCalendar(getTimeZone());
  cal.setGregorianChange(new Date(Long.MIN_VALUE));
  cal.setTime(sourceDate);
  XMLGregorianCalendar xgc = getDatatypeFactory().newXMLGregorianCalendar();
  if(cal.get(Calendar.ERA)== GregorianCalendar.BC){
    xgc.setYear(-cal.get(Calendar.YEAR));
  }else{
    xgc.setYear(cal.get(Calendar.YEAR));
  }
  xgc.setMonth(cal.get(Calendar.MONTH)+1);
  xgc.setDay(cal.get(Calendar.DAY_OF_MONTH));
  xgc.setHour(cal.get(Calendar.HOUR_OF_DAY));
  xgc.setMinute(cal.get(Calendar.MINUTE));
  xgc.setSecond(cal.get(Calendar.SECOND));
  String string= xgc.toXMLFormat();
  string = appendNanos(string, sourceDate);
  return appendTimeZone(string);
}

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.sdo

Calendar cal;
if (xgc.getTimezone() == DatatypeConstants.FIELD_UNDEFINED) {
  cal = xgc.toGregorianCalendar(getXMLConversionManager().getTimeZone(), locale, null);
  cal.clear(Calendar.ZONE_OFFSET);
} else {

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com