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


Java LocalDateTime.now方法代码示例

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


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

示例1: addSessionReminder

import org.threeten.bp.LocalDateTime; //导入方法依赖的package包/类
public void addSessionReminder(@NonNull Session session) {
    if (!isEnabled()) {
        Timber.d("SessionsReminder is not enable, skip adding session");
        return;
    }

    PendingIntent intent = createSessionReminderIntent(session);
    LocalDateTime now = LocalDateTime.now();
    LocalDateTime sessionStartTime = session.getFromTime().minusMinutes(3);
    if (!sessionStartTime.isAfter(now)) {
        Timber.w("Do not set reminder for passed session");
        return;
    }
    Timber.d("Setting reminder on %s", sessionStartTime);
    App.setExactAlarm(alarmManager, sessionStartTime.atZone(ZoneOffset.systemDefault()).toInstant().toEpochMilli(), intent);
}
 
开发者ID:Nilhcem,项目名称:droidcongr-2016,代码行数:17,代码来源:SessionsReminder.java

示例2: should_convert_network_sessions_to_app_sessions

import org.threeten.bp.LocalDateTime; //导入方法依赖的package包/类
@Test
public void should_convert_network_sessions_to_app_sessions() {
    // Given
    LocalDateTime startAt = LocalDateTime.now();
    Session session = new Session(1, startAt, 20, Room.NONE.id, singletonList(10), "title", "description");
    Map<Integer, com.nilhcem.droidconde.data.app.model.Speaker> speakersMap = new HashMap<>();
    speakersMap.put(10, new com.nilhcem.droidconde.data.app.model.Speaker(10, "ten", null, null, null, null, null, null));

    // When
    List<com.nilhcem.droidconde.data.app.model.Session> result = networkMapper.toAppSessions(singletonList(session), speakersMap);

    // Then
    assertThat(result).hasSize(1);
    assertThat(result.get(0).getId()).isEqualTo(1);
    assertThat(result.get(0).getFromTime()).isEqualTo(startAt);
    assertThat(result.get(0).getToTime()).isEqualTo(startAt.plusMinutes(20));
    assertThat(result.get(0).getRoom()).isEqualTo(Room.NONE.label);
    assertThat(result.get(0).getSpeakers().get(0).getId()).isEqualTo(10);
    assertThat(result.get(0).getSpeakers().get(0).getName()).isEqualTo("ten");
    assertThat(result.get(0).getTitle()).isEqualTo("title");
    assertThat(result.get(0).getDescription()).isEqualTo("description");
}
 
开发者ID:Nilhcem,项目名称:droidconde-2016,代码行数:23,代码来源:NetworkMapperTest.java

示例3: should_restore_from_parcelable

import org.threeten.bp.LocalDateTime; //导入方法依赖的package包/类
@Test
public void should_restore_from_parcelable() {
    // Given
    LocalDateTime time = LocalDateTime.now();
    List<Session> sessions = Arrays.asList(new Session(1, null, null, null, null, null, null), new Session(2, null, null, null, null, null, null), new Session(3, null, null, null, null, null, null));
    ScheduleSlot slot = new ScheduleSlot(time, sessions);

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

    // Then
    assertThat(fromParcel.getTime()).isEqualTo(time);
    assertThat(fromParcel.getSessions()).hasSize(3);
}
 
开发者ID:Nilhcem,项目名称:devoxxfr-2016,代码行数:18,代码来源:ScheduleSlotTest.java

示例4: should_convert_network_sessions_to_app_sessions

import org.threeten.bp.LocalDateTime; //导入方法依赖的package包/类
@Test
public void should_convert_network_sessions_to_app_sessions() {
    // Given
    LocalDateTime startAt = LocalDateTime.now();
    Session session = new Session(1, startAt, 20, Room.NONE.id, singletonList(10), "title", "description");
    Map<Integer, com.nilhcem.devfestnantes.data.app.model.Speaker> speakersMap = new HashMap<>();
    speakersMap.put(10, new com.nilhcem.devfestnantes.data.app.model.Speaker(10, "ten", null, null, null, null, null, null));

    // When
    List<com.nilhcem.devfestnantes.data.app.model.Session> result = networkMapper.toAppSessions(singletonList(session), speakersMap);

    // Then
    assertThat(result).hasSize(1);
    assertThat(result.get(0).getId()).isEqualTo(1);
    assertThat(result.get(0).getFromTime()).isEqualTo(startAt);
    assertThat(result.get(0).getToTime()).isEqualTo(startAt.plusMinutes(20));
    assertThat(result.get(0).getRoom()).isEqualTo(Room.NONE.label);
    assertThat(result.get(0).getSpeakers().get(0).getId()).isEqualTo(10);
    assertThat(result.get(0).getSpeakers().get(0).getName()).isEqualTo("ten");
    assertThat(result.get(0).getTitle()).isEqualTo("title");
    assertThat(result.get(0).getDescription()).isEqualTo("description");
}
 
开发者ID:Nilhcem,项目名称:devfestnantes-2016,代码行数:23,代码来源:NetworkMapperTest.java

示例5: should_remove_previous_session_when_adding_a_new_one_for_the_same_slot_time

import org.threeten.bp.LocalDateTime; //导入方法依赖的package包/类
@Test
public void should_remove_previous_session_when_adding_a_new_one_for_the_same_slot_time() {
    // Given
    LocalDateTime now = LocalDateTime.now();
    Map<LocalDateTime, Integer> map = new HashMap<>();
    map.put(now, 1);
    memory.setSelectedSessions(map);
    Session toAdd = new Session(3, null, null, null, null, now, now.plusMinutes(30));

    // When
    assertThat(memory.get(now)).isEqualTo(1);
    memory.toggleSessionState(toAdd, true);

    // Then
    assertThat(memory.get(now)).isEqualTo(3);
}
 
开发者ID:Nilhcem,项目名称:devfestnantes-2016,代码行数:17,代码来源:SelectedSessionsMemoryTest.java

示例6: should_convert_network_sessions_to_app_sessions

import org.threeten.bp.LocalDateTime; //导入方法依赖的package包/类
@Test
public void should_convert_network_sessions_to_app_sessions() {
    // Given
    LocalDateTime startAt = LocalDateTime.now();
    Session session = new Session(1, startAt, 20, Room.CESAR_1.id, singletonList(10), "title", "description");
    Map<Integer, com.nilhcem.droidcontn.data.app.model.Speaker> speakersMap = new HashMap<>();
    speakersMap.put(10, new com.nilhcem.droidcontn.data.app.model.Speaker(10, "ten", null, null, null, null, null, null));

    // When
    List<com.nilhcem.droidcontn.data.app.model.Session> result = networkMapper.toAppSessions(singletonList(session), speakersMap);

    // Then
    assertThat(result).hasSize(1);
    assertThat(result.get(0).getId()).isEqualTo(1);
    assertThat(result.get(0).getFromTime()).isEqualTo(startAt);
    assertThat(result.get(0).getToTime()).isEqualTo(startAt.plusMinutes(20));
    assertThat(result.get(0).getRoom()).isEqualTo(Room.CESAR_1.name);
    assertThat(result.get(0).getSpeakers().get(0).getId()).isEqualTo(10);
    assertThat(result.get(0).getSpeakers().get(0).getName()).isEqualTo("ten");
    assertThat(result.get(0).getTitle()).isEqualTo("title");
    assertThat(result.get(0).getDescription()).isEqualTo("description");
}
 
开发者ID:Nilhcem,项目名称:droidcontn-2016,代码行数:23,代码来源:NetworkMapperTest.java

示例7: AbstractsxObject

import org.threeten.bp.LocalDateTime; //导入方法依赖的package包/类
AbstractsxObject()
{
    //initial to now
    ID=0;
    title="object";
    state=1;
    content="";
    importance=0;
    begin=LocalDateTime.now();
    end=LocalDateTime.now().plusDays(10);
}
 
开发者ID:AndroidNewbies,项目名称:Sanxing,代码行数:12,代码来源:AbstractsxObject.java

示例8: Habit

import org.threeten.bp.LocalDateTime; //导入方法依赖的package包/类
public Habit()
{
    super();
    record = new ArrayList<Integer>();
    frequency=2;
    recordnumber=0;
    neednumber=1;
    need_record_all=0;
    have_record_all=0;
    nextddl=LocalDateTime.now();
}
 
开发者ID:AndroidNewbies,项目名称:Sanxing,代码行数:12,代码来源:Habit.java

示例9: next_day

import org.threeten.bp.LocalDateTime; //导入方法依赖的package包/类
public void next_day()
{
    LocalDateTime now=LocalDateTime.now();
    while (!now.isBefore(nextddl))//更新总需要
    {
        nextddl=nextddl.plusDays(get_duration());
        neednumber=get_need_record();
        need_record_all+=neednumber;
        recordnumber=0;
    }
}
 
开发者ID:AndroidNewbies,项目名称:Sanxing,代码行数:12,代码来源:Habit.java

示例10: onOptionsItemSelected

import org.threeten.bp.LocalDateTime; //导入方法依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_confirm_new_item) {
        // The verifyForm() method can be modified if necessary
        if(!verifyForm(linearLayout)) return true;
        ////////
        //Then register the changes in the database
        // Use "selectedFreq" for frequency index
        // Use "selectedImportance" for the the importance 0~4
        // Use inputTitle.getText().toString() to get the title
        // Use descriptionContent.getText().toString() to get the description
        LocalDateTime now=LocalDateTime.now();
        String s=now.toString().replace('T',' ');
        if (s.length()==16) s=s.concat(":00");
        if (s.length()>19) s=s.substring(0,19);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        habit.create_habit(inputTitle.getText().toString(),s,"2020-01-01 18:21:00",
                descriptionContent.getText().toString(),selectedImportance,selectedFreq);
        myApplication.get_habit_manager().addObject(habit);
        // finish
        Intent intent = new Intent();
        setResult(RESULT_OK, intent);
        animationSubmit();
        return true;
    }
    return super.onOptionsItemSelected(item);
}
 
开发者ID:AndroidNewbies,项目名称:Sanxing,代码行数:34,代码来源:CreateNewHabitActivity.java

示例11: onOptionsItemSelected

import org.threeten.bp.LocalDateTime; //导入方法依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will.
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_confirm_new_item) {
        // The verifyForm() method can be modified if necessary
        if(!verifyForm(linearLayout)) return true;
        ////////
        // Then register the changes in the database
        // Use "dueCalendar" for due date and time
        // Use "selectedImportance" for the the importance 0~4
        // Use inputTitle.getText().toString() to get the title
        // Use descriptionContent.getText().toString() to get the description
        LocalDateTime now=LocalDateTime.now();
        String s=now.toString().replace('T',' ');
        if (s.length()==16) s=s.concat(":00");
        if (s.length()>19) s=s.substring(0,19);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        task.create_task(inputTitle.getText().toString(),s,sdf.format(dueCalendar.getTime()).substring(0,16).concat(":00"),
                descriptionContent.getText().toString(),selectedImportance);
        myApplication.getApplicationContext();
        myApplication.get_task_manager().addObject(task);
        Intent intent = new Intent();
        intent.putExtra("task_title",inputTitle.getText().toString());
        animationSubmit();

        //pass data to the home activity
        setResult(Activity.RESULT_OK, intent);
        animationSubmit();
        return true;
    }
    return super.onOptionsItemSelected(item);
}
 
开发者ID:AndroidNewbies,项目名称:Sanxing,代码行数:38,代码来源:CreateNewTaskActivity.java

示例12: install

import org.threeten.bp.LocalDateTime; //导入方法依赖的package包/类
private void install()
{
    SharedPreferences sharedPreferences= PreferenceManager.getDefaultSharedPreferences(this);
    boolean ifinstall=sharedPreferences.getBoolean("ifinstall",false);
    if (!ifinstall)
    {
        //实例化Editor对象
        SharedPreferences.Editor editor = sharedPreferences.edit();
        //存入数据
        editor.putBoolean("ifinstall",true);//已安装
        //默认值
        editor.putBoolean("notifications_enabled",true);
        editor.putBoolean("notifications_vibrate_enabled",true);
        LocalDateTime now=LocalDateTime.now();
        now=LocalDateTime.of(now.getYear(),now.getMonth(),now.getDayOfMonth(),12,0);
        ZoneOffset zoneOffset = OffsetDateTime.now(ZoneId.systemDefault()).getOffset ();
        editor.putLong("notifications_time",now.toEpochSecond(zoneOffset)*1000);//当地12点的格林尼治时间戳
        //Log.w("Time1",String.valueOf(now.toEpochSecond(zoneOffset)*1000));
        //Log.w("Time1",String.valueOf(now.toEpochSecond(ZoneOffset.UTC)*1000));
        editor.putString("notifications_ringtone","content://settings/system/notification_sound");
        editor.putString("calendar_first_day_of_week","0");
        //提交修改
        editor.commit();
    }
}
 
开发者ID:AndroidNewbies,项目名称:Sanxing,代码行数:26,代码来源:MyApplication.java

示例13: Setting

import org.threeten.bp.LocalDateTime; //导入方法依赖的package包/类
public Setting()
{
    LocalDateTime now=LocalDateTime.now();
    callTime=LocalDateTime.of(now.getYear(),now.getMonth(),now.getDayOfMonth(),12,0);
    ifnotify=true;
    Ringtone="";
    ifvibrate=true;
}
 
开发者ID:AndroidNewbies,项目名称:Sanxing,代码行数:9,代码来源:Setting.java

示例14: should_return_speakers_when_cache_time_is_still_active

import org.threeten.bp.LocalDateTime; //导入方法依赖的package包/类
@Test
public void should_return_speakers_when_cache_time_is_still_active() {
    // Given
    cache.speakersFetchedTime = LocalDateTime.now();
    cache.speakers = speakers;

    // When
    List<Speaker> result = cache.getSpeakers();

    // Then
    assertThat(result).isEqualTo(speakers);
}
 
开发者ID:Nilhcem,项目名称:droidconat-2016,代码行数:13,代码来源:DataProviderCacheTest.java

示例15: should_set_selected_sessions

import org.threeten.bp.LocalDateTime; //导入方法依赖的package包/类
@Test
public void should_set_selected_sessions() {
    // Given
    LocalDateTime now = LocalDateTime.now();
    Map<LocalDateTime, Integer> map = new HashMap<>();
    map.put(now, 1);

    // When
    assertThat(memory.get(now)).isNull();
    memory.setSelectedSessions(map);

    // Then
    assertThat(memory.get(now)).isEqualTo(1);
}
 
开发者ID:Nilhcem,项目名称:droidcontn-2016,代码行数:15,代码来源:SelectedSessionsMemoryTest.java


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