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


Java LocalDate类代码示例

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


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

示例1: getLastWeeksMessages

import org.threeten.bp.LocalDate; //导入依赖的package包/类
private List<SlackMessagePosted> getLastWeeksMessages() {
    SlackSession slackSession = getSlackSession();

    SlackChannel slackChannel = slackSession.findChannelByName("publicaties");

    ChannelHistoryModule channelHistoryModule = ChannelHistoryModuleFactory.createChannelHistoryModule(slackSession);

    List<SlackMessagePosted> lastWeeksMesages = IntStream.of(7, 6, 5, 4, 3, 2, 1)
            .mapToObj(daysAgo -> LocalDate.now().minus(daysAgo, ChronoUnit.DAYS))
            .flatMap(date -> getMessagesOfDay(slackChannel, channelHistoryModule, date))
            .collect(toList());

    try {
        slackSession.disconnect();
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }

    return lastWeeksMesages;
}
 
开发者ID:bobvandenberge,项目名称:publicaties-generator,代码行数:21,代码来源:SlackAPI.java

示例2: fetchHistoryOfChannel

import org.threeten.bp.LocalDate; //导入依赖的package包/类
@Override
public List<SlackMessagePosted> fetchHistoryOfChannel(String channelId, LocalDate day, int numberOfMessages) {
    Map<String, String> params = new HashMap<>();
    params.put("channel", channelId);
    if (day != null) {
        ZonedDateTime start = ZonedDateTime.of(day.atStartOfDay(), ZoneId.of("UTC"));
        ZonedDateTime end = ZonedDateTime.of(day.atStartOfDay().plusDays(1).minus(1, ChronoUnit.MILLIS), ZoneId.of("UTC"));
        params.put("oldest", convertDateToSlackTimestamp(start));
        params.put("latest", convertDateToSlackTimestamp(end));
    }
    if (numberOfMessages > -1) {
        params.put("count", String.valueOf(numberOfMessages));
    } else {
        params.put("count", String.valueOf(DEFAULT_HISTORY_FETCH_SIZE));
    }
    SlackChannel channel =session.findChannelById(channelId);
    switch (channel.getType()) {
        case INSTANT_MESSAGING:
            return fetchHistoryOfChannel(params,FETCH_IM_HISTORY_COMMAND);
        case PRIVATE_GROUP:
            return fetchHistoryOfChannel(params,FETCH_GROUP_HISTORY_COMMAND);
        default:
            return fetchHistoryOfChannel(params,FETCH_CHANNEL_HISTORY_COMMAND);
    }
}
 
开发者ID:riversun,项目名称:slacklet,代码行数:26,代码来源:ChannelHistoryModuleImpl.java

示例3: parameterToString

import org.threeten.bp.LocalDate; //导入依赖的package包/类
/**
 * Format the given parameter object into string.
 *
 * @param param Parameter
 * @return String representation of the parameter
 */
public String parameterToString(Object param) {
    if (param == null) {
        return "";
    } else if (param instanceof Date || param instanceof OffsetDateTime || param instanceof LocalDate) {
        //Serialize to json string and remove the " enclosing characters
        String jsonStr = json.serialize(param);
        return jsonStr.substring(1, jsonStr.length() - 1);
    } else if (param instanceof Collection) {
        StringBuilder b = new StringBuilder();
        for (Object o : (Collection)param) {
            if (b.length() > 0) {
                b.append(",");
            }
            b.append(String.valueOf(o));
        }
        return b.toString();
    } else {
        return String.valueOf(param);
    }
}
 
开发者ID:cliffano,项目名称:swaggy-jenkins,代码行数:27,代码来源:ApiClient.java

示例4: onCreate

import org.threeten.bp.LocalDate; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    AndroidThreeTen.init(this);
    start_date = LocalDate.now();
    end_date = LocalDate.now();
    seed = DEFAULT_SEED;
    setContentView(R.layout.activity_main);

    // Load an ad into the AdMob banner view.
    AdView adView = (AdView) findViewById(R.id.adView);
    AdRequest adRequest = new AdRequest.Builder().setRequestAgent("android_studio:ad_template").build();
    adView.loadAd(adRequest);

    potd_list_view = (ListView) findViewById(R.id.potd_list);

    generate_potd_list();
}
 
开发者ID:borfast,项目名称:arrispwgen-android,代码行数:19,代码来源:MainActivity.java

示例5: getView

import org.threeten.bp.LocalDate; //导入依赖的package包/类
@NonNull
@Override
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
    // Get the data item for this position
    Map.Entry<LocalDate, String> potd = getItem(position);

    // Check if an existing view is being reused, otherwise inflate the view
    if (convertView == null) {
        convertView = LayoutInflater.from(getContext()).inflate(R.layout.potd_list_item, parent, false);
    }

    // Lookup view for data population
    TextView date = (TextView) convertView.findViewById(R.id.potd_date);
    TextView password = (TextView) convertView.findViewById(R.id.password);

    // Populate the data into the template view using the data object
    if (potd != null) {
        date.setText(potd.getKey().toString());
        password.setText(potd.getValue());
    }

    // Return the completed view to render on screen
    return convertView;
}
 
开发者ID:borfast,项目名称:arrispwgen-android,代码行数:25,代码来源:PotdListArrayAdapter.java

示例6: generate_multi

import org.threeten.bp.LocalDate; //导入依赖的package包/类
static Map<LocalDate, String> generate_multi(LocalDate start_date, LocalDate end_date, String seed) {
    if (start_date.isAfter(end_date)) {
        throw new IllegalArgumentException();
    }

    int days = (int) (1 + ChronoUnit.DAYS.between(start_date, end_date));

    // Now let's generate one password for each day
    Map<LocalDate, String> password_list = new HashMap<>();
    LocalDate date = start_date;
    for (int i = 0; i < days; i++) {
        password_list.put(date, generate(date, seed));
        date = date.plusDays(1);
    }

    return password_list;
}
 
开发者ID:borfast,项目名称:arrispwgen-android,代码行数:18,代码来源:Arrispwgen.java

示例7: fetchHistoryOfChannel

import org.threeten.bp.LocalDate; //导入依赖的package包/类
@Override
public List<SlackMessagePosted> fetchHistoryOfChannel(String channelId, LocalDate day, int numberOfMessages) {
    Map<String, String> params = new HashMap<>();
    params.put("channel", channelId);
    if (day != null) {
        ZonedDateTime start = ZonedDateTime.of(day.atStartOfDay(), ZoneId.of("UTC"));
        ZonedDateTime end = ZonedDateTime.of(day.atStartOfDay().plusDays(1).minus(1, ChronoUnit.MILLIS), ZoneId.of("UTC"));
        params.put("oldest", convertDateToSlackTimestamp(start));
        params.put("latest", convertDateToSlackTimestamp(end));
    }
    if (numberOfMessages > -1) {
        params.put("count", String.valueOf(numberOfMessages));
    } else {
        params.put("count", String.valueOf(1000));
    }
    return fetchHistoryOfChannel(params);
}
 
开发者ID:JujaLabs,项目名称:microservices,代码行数:18,代码来源:ChannelHistoryModuleImpl.java

示例8: should_restore_from_parcelable

import org.threeten.bp.LocalDate; //导入依赖的package包/类
@Test
public void should_restore_from_parcelable() {
    // Given
    LocalDate day = LocalDate.of(1985, 5, 15);
    List<ScheduleSlot> slots = singletonList(new ScheduleSlot(null, null));
    ScheduleDay scheduleDay = new ScheduleDay(day, slots);

    // When
    Parcel parcel = Parcel.obtain();
    scheduleDay.writeToParcel(parcel, 0);
    parcel.setDataPosition(0);
    ScheduleDay fromParcel = ScheduleDay.CREATOR.createFromParcel(parcel);

    // Then
    assertThat(fromParcel.getDay()).isEqualTo(day);
    assertThat(fromParcel.getSlots()).hasSize(1);
}
 
开发者ID:Nilhcem,项目名称:droidconde-2016,代码行数:18,代码来源:ScheduleDayTest.java

示例9: fetchData

import org.threeten.bp.LocalDate; //导入依赖的package包/类
private void fetchData(Action0 termination) {
    this.tracker = this.wakatimeClient.fetchLastSevenDays(HeaderFormatter.get(realm))
        .observeOn(uiScheduler)
        .subscribeOn(ioScheduler)
        .map(Wrapper::getData)
        .doOnError(viewModel::notifyError)
        .doOnTerminate(termination)
        .subscribe(
            data -> {
                viewModel.setData(data);
                viewModel.setRotationCache(data);
            }, throwable -> Timber.e(throwable, "Error while fetching data")
        );

    this.durationTracker = this.wakatimeClient.fetchDurations(HeaderFormatter.get(realm),
        LocalDate.now().format(DateTimeFormatter.ISO_DATE))
        .observeOn(uiScheduler)
        .subscribeOn(ioScheduler)
        .map(DurationWrapper::getData)
        .map(this::sumDurations)
        .map(this::formatTime)
        .doOnError(err -> Timber.w(err, "Error during processing durations"))
        .onErrorReturn(error -> "Not available")
        .subscribe(time -> viewModel.setTodayTime(time), error ->
            Timber.w(error, "Error parsing time"));
}
 
开发者ID:omgitsjoao,项目名称:wakatime-android-client,代码行数:27,代码来源:DefaultLastSevenDaysPresenter.java

示例10: call

import org.threeten.bp.LocalDate; //导入依赖的package包/类
@Override
@UiThread
public void call(final Subscriber<? super List<LocalDate>> subscriber) {
  checkUiThread();

  calendarView.setOnRangeSelectedListener(new OnRangeSelectedListener() {
    @Override
    public void onRangeSelected(@NonNull MaterialCalendarView widget, @NonNull List<CalendarDay> dates) {
      if (!subscriber.isUnsubscribed()) {
        subscriber.onNext(DateHelper.calendarDaysToLocalDates(dates));
      }
    }
  });

  subscriber.add(new MainThreadSubscription() {
    @Override
    protected void onUnsubscribe() {
      calendarView.setOnRangeSelectedListener(null);
    }
  });
}
 
开发者ID:xmartlabs,项目名称:XLMaterialCalendarView,代码行数:22,代码来源:CalendarViewRangeSelectedOnSubscribe.java

示例11: call

import org.threeten.bp.LocalDate; //导入依赖的package包/类
@Override
@UiThread
public void call(final Subscriber<? super LocalDate> subscriber) {
  checkUiThread();

  calendarView.setOnDateChangedListener(new OnDateSelectedListener() {
    @Override
    public void onDateSelected(@NonNull MaterialCalendarView widget, @NonNull CalendarDay date, boolean selected) {
      if (!subscriber.isUnsubscribed()) {
        subscriber.onNext(DateHelper.calendarDayToLocalDate(date));
      }
    }
  });

  subscriber.add(new MainThreadSubscription() {
    @Override
    protected void onUnsubscribe() {
      calendarView.setOnDateChangedListener(null);
    }
  });
}
 
开发者ID:xmartlabs,项目名称:XLMaterialCalendarView,代码行数:22,代码来源:CalendarViewDateChangeOnSubscribe.java

示例12: setUp

import org.threeten.bp.LocalDate; //导入依赖的package包/类
@Before
public void setUp() {
  gson = new GsonBuilder()
      .registerTypeHierarchyAdapter(Object.class, new RequiredFieldDeserializer())
      .registerTypeAdapter(LocalDate.class, new MillisecondsLocalDateAdapter())
      .setExclusionStrategies(new ExclusionStrategy() {
        @Override
        public boolean shouldSkipField(FieldAttributes fieldAttributes) {
          return fieldAttributes.getAnnotation(GsonExclude.class) != null;
        }

        @Override
        public boolean shouldSkipClass(Class<?> clazz) {
          return false;
        }
      })
      .create();
}
 
开发者ID:xmartlabs,项目名称:bigbang,代码行数:19,代码来源:GsonRequiredTest.java

示例13: testOtherTypeAdaptersAreStillWorking

import org.threeten.bp.LocalDate; //导入依赖的package包/类
@Test
public void testOtherTypeAdaptersAreStillWorking() {
  TestInnerClass innerClass = TestInnerClass.builder()
      .requiredObject("obj")
      .build();
  TestClass testClass = TestClass.builder()
      .innerRequiredObject(innerClass)
      .requiredField("obj")
      .excluded("Something")
      .date(LocalDate.now())
      .build();

  String value = gson.toJson(testClass);

  MillisecondsLocalDateAdapter adapter = new MillisecondsLocalDateAdapter();
  String serializedDate  = adapter.serialize(testClass.date, LocalDate.class, null).getAsString();

  assertThat(value.contains(serializedDate), is(true));
}
 
开发者ID:xmartlabs,项目名称:bigbang,代码行数:20,代码来源:GsonRequiredTest.java

示例14: fetchUpdatingHistoryOfChannel

import org.threeten.bp.LocalDate; //导入依赖的package包/类
@Override
public List<SlackMessagePosted> fetchUpdatingHistoryOfChannel(String channelId, LocalDate day, int numberOfMessages) {
    List<SlackMessagePosted> messages = fetchHistoryOfChannel(channelId, day, numberOfMessages);
    session.addReactionAddedListener(new ChannelHistoryReactionAddedListener(messages));
    session.addReactionRemovedListener(new ChannelHistoryReactionRemovedListener(messages));
    session.addMessagePostedListener(new ChannelHistoryMessagePostedListener(messages));
    return messages;
}
 
开发者ID:riversun,项目名称:slacklet,代码行数:9,代码来源:ChannelHistoryModuleImpl.java

示例15: JSON

import org.threeten.bp.LocalDate; //导入依赖的package包/类
public JSON() {
    gson = new GsonBuilder()
        .registerTypeAdapter(Date.class, dateTypeAdapter)
        .registerTypeAdapter(java.sql.Date.class, sqlDateTypeAdapter)
        .registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter)
        .registerTypeAdapter(LocalDate.class, localDateTypeAdapter)
        .create();
}
 
开发者ID:cliffano,项目名称:swaggy-jenkins,代码行数:9,代码来源:JSON.java


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