本文整理了Java中org.joda.time.DateTime.toGregorianCalendar()
方法的一些代码示例,展示了DateTime.toGregorianCalendar()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DateTime.toGregorianCalendar()
方法的具体详情如下:
包路径:org.joda.time.DateTime
类名称:DateTime
方法名:toGregorianCalendar
暂无
代码示例来源:origin: spring-projects/spring-framework
@Override
public Calendar convert(DateTime source) {
return source.toGregorianCalendar();
}
}
代码示例来源:origin: org.springframework/spring-context
@Override
public Calendar convert(DateTime source) {
return source.toGregorianCalendar();
}
}
代码示例来源:origin: com.thoughtworks.xstream/xstream
public Object fromString(final String str) {
for (int i = 0; i < formattersUTC.length ; ++i) {
final DateTimeFormatter formatter = formattersUTC[i];
try {
final DateTime dt = formatter.parseDateTime(str);
final Calendar calendar = dt.toGregorianCalendar();
calendar.setTimeZone(TimeZone.getDefault());
return calendar;
} catch (final IllegalArgumentException e) {
// try with next formatter
}
}
final DateTimeZone dateTimeZone = DateTimeZone.forTimeZone(TimeZone.getDefault());
for (int i = 0; i < formattersNoUTC.length ; ++i) {
final DateTimeFormatter element = formattersNoUTC[i];
try {
final DateTimeFormatter formatter = element.withZone(dateTimeZone);
final DateTime dt = formatter.parseDateTime(str);
final Calendar calendar = dt.toGregorianCalendar();
calendar.setTimeZone(TimeZone.getDefault());
return calendar;
} catch (final IllegalArgumentException e) {
// try with next formatter
}
}
final ConversionException exception = new ConversionException("Cannot parse date");
exception.add("date", str);
throw exception;
}
代码示例来源:origin: stackoverflow.com
DateTimeFormatter formatter =
DateTimeFormat.forPattern("your pattern").withOffsetParsed();
DateTime dateTime = formatter.parseDateTime("your input");
GregorianCalendar cal = dateTime.toGregorianCalendar();
代码示例来源:origin: org.modeshape/modeshape-graph
/**
* {@inheritDoc}
*/
public GregorianCalendar toGregorianCalendar() {
return this.instance.toGregorianCalendar();
}
代码示例来源:origin: apache/servicemix-bundles
@Override
public Calendar convert(DateTime source) {
return source.toGregorianCalendar();
}
}
代码示例来源:origin: stackoverflow.com
DateTimeFormatter formatter =
DateTimeFormat.forPattern("ddmmyyyy").withOffsetParsed();
DateTime dateTime = formatter.parseDateTime("dt");
GregorianCalendar cal = dateTime.toGregorianCalendar();
代码示例来源:origin: stackoverflow.com
String dateStr = "1/12/2014";
DateTimeFormatter formatter = DateTimeFormat.forPattern("dd/MM/yyyy");
DateTime dateTime = formatter.parseDateTime(dateStr);
GregorianCalendar gc = dateTime.toGregorianCalendar();
代码示例来源:origin: pl.edu.icm.yadda/yadda-aas2
public Object convert(Object source, URI targetDataType)
throws AttributeValueDataConverterException {
DateTime dateTimeSource = (DateTime) source;
if (targetDataType.equals(SUPPORTED_URI)) {
return datatypeFactory.newXMLGregorianCalendar(
dateTimeSource.toGregorianCalendar());
} else {
log.warn("No convertion performed. Expected URI: "+SUPPORTED_URI+
", got: "+targetDataType);
return source;
}
}
代码示例来源:origin: archfirst/bullsfirst-server-java
public XMLGregorianCalendar marshal(DateTime val) throws Exception {
try {
GregorianCalendar calendar = val.toGregorianCalendar();
return DatatypeFactory.newInstance().newXMLGregorianCalendar(calendar);
}
catch (DatatypeConfigurationException e) {
throw new IllegalArgumentException();
}
}
}
代码示例来源:origin: org.gdl-lang.gdl-tools/cds-core
static Double calculateDurationAgainstDateTime(String value, DateTime operationDateTime, String symbol) {
String units = StringUtils.substringAfter(value, ",").trim();
String minusSignIfSubtraction = "-".equals(symbol) ? "-" : "";
String amount = minusSignIfSubtraction + substringBefore(value, ",");
Calendar resultDateTime = new DateTime(operationDateTime).toGregorianCalendar();
if (amount.contains(".")) {
logger.warn(format("Invalid amount detected while doing date operations '%s'. Using double as integer.", amount));
amount = substringBefore(amount, ".");
}
resultDateTime.add(ucumToCalendar(units), Integer.parseInt(amount));
return (double) Math.abs(resultDateTime.getTimeInMillis() - operationDateTime.toGregorianCalendar().getTimeInMillis());
}
代码示例来源:origin: dhis2/dhis2-core
/**
* Converts dateUnit to JDK Calendar
*
* @return Populated JDK Calendar object
*/
public java.util.Calendar toJdkCalendar()
{
return toJodaDateTime().toGregorianCalendar();
}
代码示例来源:origin: archfirst/bullsfirst-server-java
public XMLGregorianCalendar marshal(LocalDate val) throws Exception {
try {
GregorianCalendar calendar = val.toDateTimeAtStartOfDay().toGregorianCalendar();
return DatatypeFactory.newInstance().newXMLGregorianCalendar(calendar);
}
catch (DatatypeConfigurationException e) {
throw new IllegalArgumentException();
}
}
}
代码示例来源:origin: org.n52.sensorweb/oxf-common
@Override
public Calendar getCalendar() {
DateTime dateTime = DateTime.parse(toISO8601Format());
return dateTime.toGregorianCalendar();
}
代码示例来源:origin: org.jruby/jruby-complete
private static int formatWeekYear(DateTime dt, int firstDayOfWeek) {
java.util.Calendar dtCalendar = dt.toGregorianCalendar();
dtCalendar.setFirstDayOfWeek(firstDayOfWeek);
dtCalendar.setMinimalDaysInFirstWeek(7);
int value = dtCalendar.get(java.util.Calendar.WEEK_OF_YEAR);
if ((value == 52 || value == 53) && (dtCalendar.get(Calendar.MONTH) == Calendar.JANUARY )) {
// MRI behavior: Week values are monotonous.
// So, weeks that effectively belong to previous year,
// will get the value of 0, not 52 or 53, as in Java.
value = 0;
}
return value;
}
代码示例来源:origin: org.jruby/jruby-core
private static int formatWeekYear(DateTime dt, int firstDayOfWeek) {
java.util.Calendar dtCalendar = dt.toGregorianCalendar();
dtCalendar.setFirstDayOfWeek(firstDayOfWeek);
dtCalendar.setMinimalDaysInFirstWeek(7);
int value = dtCalendar.get(java.util.Calendar.WEEK_OF_YEAR);
if ((value == 52 || value == 53) && (dtCalendar.get(Calendar.MONTH) == Calendar.JANUARY )) {
// MRI behavior: Week values are monotonous.
// So, weeks that effectively belong to previous year,
// will get the value of 0, not 52 or 53, as in Java.
value = 0;
}
return value;
}
代码示例来源:origin: org.apache.marmotta/marmotta-commons
/**
* Create a cache key for the date literal with the given date. Converts the date
* to a XMLGregorianCalendar with UTC timezone and then calls the method above.
*
* @param date date object of the date literal
* @param type datatype URI of the literal
* @return a 64bit hash key for the literal
*/
public static String createCacheKey(DateTime date, String type) {
GregorianCalendar cal = date.toGregorianCalendar();
XMLGregorianCalendar xml_cal = dtf.newXMLGregorianCalendar(cal);
return createCacheKey(xml_cal.toXMLFormat(), (String)null, type);
}
代码示例来源:origin: org.jasig.portlet.utils/portlet-ws-util
public static String printTime(LocalTime localTime) {
final DateTime dateTime = localTime.toDateTimeToday(DateTimeZone.UTC);
final GregorianCalendar cal = dateTime.toGregorianCalendar();
return DatatypeConverter.printTime(cal);
}
代码示例来源:origin: org.dd4t/dd4t-mvc-support
public String getXMLDateAsString(DateTime date) {
try {
GregorianCalendar c = date.toGregorianCalendar();
XMLGregorianCalendar xmlDate = DatatypeFactory.newInstance().newXMLGregorianCalendar(c);
xmlDate.setMillisecond(DatatypeConstants.FIELD_UNDEFINED);
xmlDate.setTimezone(DatatypeConstants.FIELD_UNDEFINED);
return xmlDate.toXMLFormat();
} catch (DatatypeConfigurationException e) {
LOG.error(e.getLocalizedMessage(), e);
}
return "";
}
代码示例来源:origin: MegaMek/mekhq
@Override
public void actionPerformed(ActionEvent e) {
DateChooser dc = new DateChooser((content instanceof Frame) ? (Frame) content : null, date.toGregorianCalendar());
if (dc.showDateChooser() == DateChooser.OK_OPTION) {
date = Utilities.getDateTimeDay(dc.getDate());
updateDate();
}
}
});
内容来源于网络,如有侵权,请联系作者删除!