java.text.DateFormat.getCalendar()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(8.8k)|赞(0)|评价(0)|浏览(193)

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

DateFormat.getCalendar介绍

[英]Returns the calendar used by this DateFormat.
[中]返回此日期格式使用的日历。

代码示例

代码示例来源:origin: commons-validator/commons-validator

/**
   * <p>Convert the parsed <code>Date</code> to a <code>Calendar</code>.</p>
   *
   * @param value The parsed <code>Date</code> object created.
   * @param formatter The Format used to parse the value with.
   * @return The parsed value converted to a <code>Calendar</code>.
   */
  @Override
  protected Object processParsedValue(Object value, Format formatter) {
    return ((DateFormat)formatter).getCalendar();
  }
}

代码示例来源:origin: commons-validator/commons-validator

/**
 * <p>Convert the parsed <code>Date</code> to a <code>Calendar</code>.</p>
 *
 * @param value The parsed <code>Date</code> object created.
 * @param formatter The Format used to parse the value with.
 * @return The parsed value converted to a <code>Calendar</code>.
 */
@Override
protected Object processParsedValue(Object value, Format formatter) {
  return ((DateFormat)formatter).getCalendar();
}

代码示例来源:origin: commons-beanutils/commons-beanutils

/**
 * Parse a String into a <code>Calendar</code> object
 * using the specified <code>DateFormat</code>.
 *
 * @param sourceType The type of the value being converted
 * @param targetType The type to convert the value to
 * @param value The String date value.
 * @param format The DateFormat to parse the String value.
 *
 * @return The converted Calendar object.
 * @throws ConversionException if the String cannot be converted.
 */
private Calendar parse(final Class<?> sourceType, final Class<?> targetType, final String value, final DateFormat format) {
  logFormat("Parsing", format);
  format.setLenient(false);
  final ParsePosition pos = new ParsePosition(0);
  final Date parsedDate = format.parse(value, pos); // ignore the result (use the Calendar)
  if (pos.getErrorIndex() >= 0 || pos.getIndex() != value.length() || parsedDate == null) {
    String msg = "Error converting '" + toString(sourceType) + "' to '" + toString(targetType) + "'";
    if (format instanceof SimpleDateFormat) {
      msg += " using pattern '" + ((SimpleDateFormat)format).toPattern() + "'";
    }
    if (log().isDebugEnabled()) {
      log().debug("    " + msg);
    }
    throw new ConversionException(msg);
  }
  final Calendar calendar = format.getCalendar();
  return calendar;
}

代码示例来源:origin: wildfly/wildfly

/**
 * Parse a String into a <code>Calendar</code> object
 * using the specified <code>DateFormat</code>.
 *
 * @param sourceType The type of the value being converted
 * @param targetType The type to convert the value to
 * @param value The String date value.
 * @param format The DateFormat to parse the String value.
 *
 * @return The converted Calendar object.
 * @throws ConversionException if the String cannot be converted.
 */
private Calendar parse(final Class<?> sourceType, final Class<?> targetType, final String value, final DateFormat format) {
  logFormat("Parsing", format);
  format.setLenient(false);
  final ParsePosition pos = new ParsePosition(0);
  final Date parsedDate = format.parse(value, pos); // ignore the result (use the Calendar)
  if (pos.getErrorIndex() >= 0 || pos.getIndex() != value.length() || parsedDate == null) {
    String msg = "Error converting '" + toString(sourceType) + "' to '" + toString(targetType) + "'";
    if (format instanceof SimpleDateFormat) {
      msg += " using pattern '" + ((SimpleDateFormat)format).toPattern() + "'";
    }
    if (log().isDebugEnabled()) {
      log().debug("    " + msg);
    }
    throw new ConversionException(msg);
  }
  final Calendar calendar = format.getCalendar();
  return calendar;
}

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

return localSimpleDateFormat.get().getCalendar();

代码示例来源:origin: de.knightsoft-net/gwt-commons-validator

/**
 * <p>Convert the parsed <code>Date</code> to a <code>Calendar</code>.</p>
 *
 * @param value The parsed <code>Date</code> object created.
 * @param formatter The Format used to parse the value with.
 * @return The parsed value converted to a <code>Calendar</code>.
 */
@Override
protected Object processParsedValue(Object value, Format formatter) {
  return ((DateFormat)formatter).getCalendar();
}

代码示例来源:origin: de.knightsoft-net/gwt-commons-validator

/**
   * <p>Convert the parsed <code>Date</code> to a <code>Calendar</code>.</p>
   *
   * @param value The parsed <code>Date</code> object created.
   * @param formatter The Format used to parse the value with.
   * @return The parsed value converted to a <code>Calendar</code>.
   */
  @Override
  protected Object processParsedValue(Object value, Format formatter) {
    return ((DateFormat)formatter).getCalendar();
  }
}

代码示例来源:origin: org.apache.commons/com.springsource.org.apache.commons.validator

/**
   * <p>Convert the parsed <code>Date</code> to a <code>Calendar</code>.</p>
   * 
   * @param value The parsed <code>Date</code> object created.
   * @param formatter The Format used to parse the value with.
   * @return The parsed value converted to a <code>Calendar</code>.
   */
  protected Object processParsedValue(Object value, Format formatter) {
    return ((DateFormat)formatter).getCalendar();
  }
}

代码示例来源:origin: org.apache.commons/com.springsource.org.apache.commons.validator

/**
 * <p>Convert the parsed <code>Date</code> to a <code>Calendar</code>.</p>
 * 
 * @param value The parsed <code>Date</code> object created.
 * @param formatter The Format used to parse the value with.
 * @return The parsed value converted to a <code>Calendar</code>.
 */
protected Object processParsedValue(Object value, Format formatter) {
  return ((DateFormat)formatter).getCalendar();
}

代码示例来源:origin: org.jxmpp/jxmpp-core

private static Calendar parseXEP91Date(String stampString, DateFormat dateFormat) {
  try {
    dateFormat.parse(stampString);
    return dateFormat.getCalendar();
  } catch (ParseException e) {
    return null;
  }
}

代码示例来源:origin: tiandawu/IotXmpp

private static Calendar parseXEP91Date(String stampString, DateFormat dateFormat) {
  try {
    synchronized (dateFormat) {
      dateFormat.parse(stampString);
      return dateFormat.getCalendar();
    }
  }
  catch (ParseException e) {
    return null;
  }
}

代码示例来源:origin: org.igniterealtime.smack/smackx

private Calendar parseXEP91Date(String stampString, DateFormat dateFormat) {
  try {
    synchronized (dateFormat) {
      dateFormat.parse(stampString);
      return dateFormat.getCalendar();
    }
  }
  catch (ParseException e) {
    return null;
  }
}

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

String input_format = "EEE MMMMM dd HH:mm:ss Z yyyy";
 String input_value="Wed Jun 13 17:05:44 +0000 2012";
 Date date=null;
 SimpleDateFormat sdf = new SimpleDateFormat(input_format);
 try {
   date = sdf.parse(input_value);
 } catch (ParseException e) {
   e.printStackTrace();
 }
 Calendar calendar = sdf.getCalendar();
 calendar.setTime(date);

代码示例来源:origin: org.ihtsdo/wb-api

public long getTimestampAsLong() {
   DateFormat dfm = new SimpleDateFormat(DEFAULT_TIME_STAMP);
   try {
    dfm.parse(testTimestampBefore);
     Calendar c = dfm.getCalendar();
     c.add(Calendar.DAY_OF_MONTH, 1);
          return c.getTimeInMillis();
   } catch (ParseException e) {
    return -1;
  }
}

代码示例来源:origin: uk.org.mygrid.resources/boca-model

public static Calendar parseDateTime(String dateTime) throws ParseException {
  synchronized (dateTimeFormat) {
    try {
      Calendar calendar = (Calendar) dateTimeFormat.getCalendar().clone();
      calendar.setTime(dateTimeFormat.parse(dateTime));
      calendar.setTimeZone(TimeZone.getTimeZone("UTC"));
      return calendar;
    } catch (Throwable e) {
      throw new ParseException("Failed to parse date/time string \"" + dateTime + "\".", 0);
    }
  }
}

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

DateFormat originalDateFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss Z yyyy");
 DateFormat targetDateFormat = new SimpleDateFormat("EEE., MMM. dd, yyyy");
 originalDateFormat.parse(origDateString);
 targetDateFormat.setCalendar(originalDateFormat.getCalendar());
 return targetDateFormat.format(targetDateFormat.getCalendar().getTime());

代码示例来源:origin: com.gitee.rslai.base.tool/servertest

private Calendar parse(String value, DateFormat format) {
  format.setLenient(false);
  ParsePosition pos = new ParsePosition(0);
  java.util.Date parsedDate = format.parse(value, pos);
  if ((pos.getErrorIndex() >= 0) || (pos.getIndex() != value.length()) || (parsedDate == null)) {
    throw new RuntimeException("Can not format " + value + " to:" + format);
  }
  return format.getCalendar();
}

代码示例来源:origin: com.atlassian.jira/jira-core

@Override
public Calendar getCalendar()
{
  return delegate.get().getCalendar();
}

代码示例来源:origin: at.bestsolution.eclipse/com.ibm.icu.base

/**
 * Returns the calendar associated with this date/time formatter.
 * @return the calendar associated with this date/time formatter.
 * @stable ICU 2.0
 */
public Calendar getCalendar()
{
  return new Calendar(dateFormat.getCalendar());
}

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

public java.util.Calendar getCalendar()
{
  Capturer.capture(Instrumenter.CAPTURE_ID_JAVA_TEXT_DATEFORMAT, this, "getCalendar", "()Ljava/util/Calendar;", new Object[] {});
  java.util.Calendar ret = new Calendar(super.getCalendar());
  Capturer.enable(Instrumenter.CAPTURE_ID_JAVA_TEXT_DATEFORMAT, this, ret);
  return ret;
}

相关文章