当前位置: 首页>>代码示例>>Java>>正文


Java MonthDay类代码示例

本文整理汇总了Java中org.joda.time.MonthDay的典型用法代码示例。如果您正苦于以下问题:Java MonthDay类的具体用法?Java MonthDay怎么用?Java MonthDay使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MonthDay类属于org.joda.time包,在下文中一共展示了MonthDay类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getNextAnniversary

import org.joda.time.MonthDay; //导入依赖的package包/类
/**
 * Gets the anniversary date not yet passed (with delta of 1 day)
 * @param date Date
 * @return Next anniversary in the year
 */
public static Date getNextAnniversary(Date date) {
    DateTime dateTimeNow = DateTime.now();
    MonthDay monthDayNow = MonthDay.now();
    MonthDay monthDayOfNextDate = MonthDay.fromDateFields(date);
    if(monthDayNow.isEqual(monthDayOfNextDate)) {
        DateTime inputDate = new DateTime(date);
        return dateTimeNow
                .withHourOfDay(inputDate.getHourOfDay())
                .withMinuteOfHour(inputDate.getMinuteOfHour())
                .withSecondOfMinute(inputDate.getSecondOfMinute())
                .withMillisOfSecond(inputDate.getMillisOfSecond()).toDate();
    } if(monthDayNow.isBefore(monthDayOfNextDate))
        return new DateTime(date).withYear(dateTimeNow.getYear()).toDate();
    else {
        DateTime dateTimeOfNextDate = new DateTime(date).withYear(dateTimeNow.getYear()).plusYears(1);
        return dateTimeOfNextDate.toDate();
    }
}
 
开发者ID:Kunzisoft,项目名称:RememBirthday,代码行数:24,代码来源:DateUnknownYear.java

示例2: extractMonthDayNamed

import org.joda.time.MonthDay; //导入依赖的package包/类
public MonthDay extractMonthDayNamed(final String parameterName, final JsonElement element) {

        MonthDay value = null;

        if (element.isJsonObject()) {
            final JsonObject object = element.getAsJsonObject();

            final String monthDayFormat = extractMonthDayFormatParameter(object);
            final Locale clientApplicationLocale = extractLocaleParameter(object);
            value = extractMonthDayNamed(parameterName, object, monthDayFormat, clientApplicationLocale);
        }
        return value;
    }
 
开发者ID:openMF,项目名称:message-gateway,代码行数:14,代码来源:JsonParserHelper.java

示例3: daysBetweenTodayAnd

import org.joda.time.MonthDay; //导入依赖的package包/类
/**
 * Return number of days between today and the next date in a year
 * @param date date for calculate delta
 * @return Number of days always >= 0
 */
public static int daysBetweenTodayAnd(Date date) {
    MonthDay monthDayNow = MonthDay.now();
    MonthDay monthDayOfNextDate = MonthDay.fromDateFields(date);
    if(monthDayNow.isEqual(monthDayOfNextDate))
        return 0;
    if(monthDayNow.isBefore(monthDayOfNextDate))
        return Days.daysBetween(monthDayNow, monthDayOfNextDate).getDays();
    else {
        DateTime dateTimeNow = DateTime.now();
        DateTime dateTimeOfNextDate = new DateTime(date).withYear(dateTimeNow.getYear()).plusYears(1);
        return Days.daysBetween(DateTime.now(), dateTimeOfNextDate).getDays();
    }
}
 
开发者ID:Kunzisoft,项目名称:RememBirthday,代码行数:19,代码来源:DateUnknownYear.java

示例4: buildBirthday

import org.joda.time.MonthDay; //导入依赖的package包/类
private Birthday buildBirthday(ContentResolver contentResolver, Cursor c) {
    String birthDate = c.getString(1);
    if (birthDate == null) return null;

    // Analyze birthday string
    try {
        Matcher regexMatcher = regexDate.matcher(birthDate);

        if (regexMatcher.find()) {
            Birthday birthday = new Birthday(contentResolver, c.getLong(0));

            // Birthday *must* have a display name
            if (birthday.displayName == null) return null;

            birthday.birthdayDate = new MonthDay(
                    Integer.parseInt(regexMatcher.group(2)),
                    Integer.parseInt(regexMatcher.group(3))
            );

            if (!"-".equals(regexMatcher.group(1))) {
                birthday.year = Integer.parseInt(regexMatcher.group(1));
                birthday.unknownYear = false;
            }

            return birthday;
        }
    }
    catch (Exception e) {
        Log.e(TAG, "Error while analyzing birthday", e);
        return null;
    }

    return null;
}
 
开发者ID:nicopico-dev,项目名称:dashclock-birthday,代码行数:35,代码来源:BirthdayRetriever.java

示例5: read

import org.joda.time.MonthDay; //导入依赖的package包/类
@Override
public MonthDay read(JsonReader in) throws IOException {
  if (in.peek() == JsonToken.NULL) {
    in.nextNull();
    return null;
  }
  return MonthDay.parse(in.nextString());
}
 
开发者ID:google-gson,项目名称:typeadapters,代码行数:9,代码来源:MonthDayTypeAdapter.java

示例6: creates_instance_of_MonthDay

import org.joda.time.MonthDay; //导入依赖的package包/类
@Test
public void creates_instance_of_MonthDay() {
    MonthDay monthDay = fixture.create(MonthDay.class);
    assertThat(monthDay, notNullValue());
    assertThat(monthDay.getMonthOfYear(), is(1));
    assertThat(monthDay.getDayOfMonth(), is(1));
}
 
开发者ID:FlexTradeUKLtd,项目名称:jfixture,代码行数:8,代码来源:TestAllClassDataTypesAreSupported.java

示例7: deserialize

import org.joda.time.MonthDay; //导入依赖的package包/类
@Override
public MonthDay deserialize(final JsonParser p, final DeserializationContext ctxt) throws IOException, JsonProcessingException {

    String str = p.getText().trim();

    if (str.isEmpty()) {
        return null;
    }

    return MonthDay.parse(str, formatter);
}
 
开发者ID:isa-group,项目名称:ppinot,代码行数:12,代码来源:MonthDayDeserializer.java

示例8: extractMonthDayNamed

import org.joda.time.MonthDay; //导入依赖的package包/类
public MonthDay extractMonthDayNamed(final String parameterName, final JsonElement element) {
    return this.helperDelegator.extractMonthDayNamed(parameterName, element);
}
 
开发者ID:openMF,项目名称:message-gateway,代码行数:4,代码来源:FromJsonHelper.java

示例9: parse

import org.joda.time.MonthDay; //导入依赖的package包/类
@Override
public MonthDay parse(String text, Locale locale) throws ParseException {
	return MonthDay.parse(text);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:5,代码来源:MonthDayFormatter.java

示例10: print

import org.joda.time.MonthDay; //导入依赖的package包/类
@Override
public String print(MonthDay object, Locale locale) {
	return object.toString();
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:5,代码来源:MonthDayFormatter.java

示例11: registerAdditionalFormatters

import org.joda.time.MonthDay; //导入依赖的package包/类
public static void registerAdditionalFormatters(FormatterRegistry registry) {
	registry.addFormatterForFieldType(YearMonth.class, new YearMonthFormatter());
	registry.addFormatterForFieldType(MonthDay.class, new MonthDayFormatter());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:5,代码来源:JodaTimeFormatterRegistrar.java

示例12: getMonthDay

import org.joda.time.MonthDay; //导入依赖的package包/类
public MonthDay getMonthDay() {
	return monthDay;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:4,代码来源:JodaTimeFormattingTests.java

示例13: setMonthDay

import org.joda.time.MonthDay; //导入依赖的package包/类
public void setMonthDay(MonthDay monthDay) {
	this.monthDay = monthDay;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:4,代码来源:JodaTimeFormattingTests.java

示例14: testSerialization

import org.joda.time.MonthDay; //导入依赖的package包/类
@Test
public void testSerialization() {
  MonthDay monthDay = new MonthDay(3,30);
  String json = gson.toJson(monthDay);
  assertEquals("\"--03-30\"", json);
}
 
开发者ID:google-gson,项目名称:typeadapters,代码行数:7,代码来源:MonthDayTypeAdapterTest.java

示例15: testDeserialization

import org.joda.time.MonthDay; //导入依赖的package包/类
@Test
public void testDeserialization() {
  MonthDay monthDay = gson.fromJson("\"--03-30\"", MonthDay.class);
  assertEquals(3, monthDay.getMonthOfYear());
  assertEquals(30, monthDay.getDayOfMonth());
}
 
开发者ID:google-gson,项目名称:typeadapters,代码行数:7,代码来源:MonthDayTypeAdapterTest.java


注:本文中的org.joda.time.MonthDay类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。