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


Java LocalDateTime.of方法代码示例

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


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

示例1: addRecord

import org.threeten.bp.LocalDateTime; //导入方法依赖的package包/类
public void addRecord()
{
    if (recordnumber<neednumber)
    {
        recordnumber++;
        have_record_all++;
    }
    if (recordnumber == neednumber){
        //list add days from today to begin
        long diff = 0;
        LocalDateTime begindatetime=getBeginLocalDate();
        LocalDateTime begindate=LocalDateTime.of(begindatetime.getYear(),begindatetime.getMonth(),
                begindatetime.getDayOfMonth(),0,0);
        diff = LocalDateTime.now().toEpochSecond(ZoneOffset.UTC)-begindate.toEpochSecond(ZoneOffset.UTC);
        int diff_int = (int)diff;
        Integer day = diff_int/60/60/24;
        Log.e("Ken: dif for habits", String.valueOf(diff)+" "+diff+" "+day);
        record.add(day);
    }
}
 
开发者ID:AndroidNewbies,项目名称:Sanxing,代码行数:21,代码来源:Habit.java

示例2: mapPackageInfoToVersion

import org.threeten.bp.LocalDateTime; //导入方法依赖的package包/类
@Test public void mapPackageInfoToVersion() {
  LocalDateTime mockNow = LocalDateTime.of(2016, 1, 1, 0, 0);
  PackageInfo packageInfo = MockPackageInfo.TEST;
  App app = MockApp.TEST;

  when(clock.now()).thenReturn(mockNow);

  ToVersionMapper mapper = new ToVersionMapper(clock, app.id());
  Version expectedVersion = Version.create(app.id(),
      packageInfo.versionCode,
      packageInfo.versionName,
      mockNow);

  Version version = mapper.map(MockPackageInfo.TEST);
  assertThat(version).isEqualTo(expectedVersion);
}
 
开发者ID:philipphager,项目名称:disclosure-android-app,代码行数:17,代码来源:ToVersionMapperShould.java

示例3: resetAfterRestart

import org.threeten.bp.LocalDateTime; //导入方法依赖的package包/类
@Test @SuppressWarnings("PMD.JUnitTestContainsTooManyAsserts")
public void resetAfterRestart() {
  LocalDateTime firstMockStart = LocalDateTime.of(2016, 1, 1, 0, 0, 0);
  LocalDateTime firstMockEnd = LocalDateTime.of(2016, 1, 1, 0, 1, 0);

  when(clock.now()).thenReturn(firstMockStart);
  stopwatch.start();
  when(clock.now()).thenReturn(firstMockEnd);
  stopwatch.stop();

  Duration firstActualDuration = Duration.between(firstMockStart, firstMockEnd);
  Duration firstMeasuredDuration = stopwatch.getDuration();
  assertThat(firstMeasuredDuration).isEqualTo(firstActualDuration);

  LocalDateTime secondMockStart = LocalDateTime.of(2016, 1, 1, 0, 5, 0);
  LocalDateTime secondMockEnd = LocalDateTime.of(2016, 1, 1, 0, 10, 0);

  when(clock.now()).thenReturn(secondMockStart);
  stopwatch.start();
  when(clock.now()).thenReturn(secondMockEnd);
  stopwatch.stop();

  Duration secondActualDuration = Duration.between(secondMockStart, secondMockEnd);
  Duration secondMeasuredDuration = stopwatch.getDuration();
  assertThat(secondMeasuredDuration).isEqualTo(secondActualDuration);
}
 
开发者ID:philipphager,项目名称:disclosure-android-app,代码行数:27,代码来源:StopwatchShould.java

示例4: should_convert_sessions_list_into_schedule

import org.threeten.bp.LocalDateTime; //导入方法依赖的package包/类
@Test
public void should_convert_sessions_list_into_schedule() {
    // Given
    LocalDateTime slot1 = LocalDateTime.of(2016, 3, 15, 8, 10);
    LocalDateTime slot2 = slot1.plusHours(1);
    LocalDateTime slot3 = slot2.plusHours(1);
    LocalDateTime slot4 = slot1.plusDays(1);
    Session session1 = new Session(1, "room1", singletonList(speaker1), "title1", "desc1", slot1, slot1.plusHours(1));
    Session session2 = new Session(2, "room2", singletonList(speaker2), "title2", "desc2", slot1, slot1.plusHours(1));
    Session session3 = new Session(3, "room1", singletonList(speaker3), "title3", "desc3", slot2, slot2.plusHours(1));
    Session session4 = new Session(4, "room1", singletonList(speaker4), "title4", "desc4", slot3, slot3.plusHours(1));
    Session session5 = new Session(5, "room1", singletonList(speaker5), "title5", "desc5", slot4, slot4.plusHours(1));

    // When
    Schedule result = appMapper.toSchedule(Arrays.asList(session1, session2, session3, session4, session5));

    // Then
    assertThat(result).hasSize(2);
    assertThat(result.get(0).getDay()).isEqualTo(slot1.toLocalDate());
    assertThat(result.get(0).getSlots()).hasSize(3);
    assertThat(result.get(0).getSlots().get(0).getSessions()).containsAllOf(session1, session2);
    assertThat(result.get(0).getSlots().get(0).getTime()).isEqualTo(slot1);
    assertThat(result.get(0).getSlots().get(1).getSessions()).containsExactly(session3);
    assertThat(result.get(1).getSlots()).hasSize(1);
    assertThat(result.get(1).getSlots().get(0).getSessions()).containsExactly(session5);
}
 
开发者ID:Nilhcem,项目名称:droidconde-2016,代码行数:27,代码来源:AppMapperTest.java

示例5: create_habit

import org.threeten.bp.LocalDateTime; //导入方法依赖的package包/类
public void create_habit(String title,String begindate,String enddate,String content,
                         int important, int frequency)
{
    super.create_object(title, begindate, enddate, content, important);
    this.frequency=frequency;
    nextddl=LocalDateTime.of(getBeginLocalDate().getYear(),getBeginLocalDate().getMonth(),
            getBeginLocalDate().getDayOfMonth(),0,0,0);
    need_record_all=0;
    have_record_all=0;
    recordnumber=0;
    next_day();//设置第一次的record
}
 
开发者ID:AndroidNewbies,项目名称:Sanxing,代码行数:13,代码来源:Habit.java

示例6: 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

示例7: 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

示例8: measureDurationTime

import org.threeten.bp.LocalDateTime; //导入方法依赖的package包/类
@Test public void measureDurationTime() {
  LocalDateTime mockStart = LocalDateTime.of(2016, 1, 1, 0, 0, 0);
  LocalDateTime mockEnd = LocalDateTime.of(2016, 1, 1, 0, 1, 0);

  when(clock.now()).thenReturn(mockStart);
  stopwatch.start();

  when(clock.now()).thenReturn(mockEnd);
  stopwatch.stop();

  assertThat(stopwatch.getDuration()).isEqualTo(Duration.between(mockStart, mockEnd));
}
 
开发者ID:philipphager,项目名称:disclosure-android-app,代码行数:13,代码来源:StopwatchShould.java

示例9: correctDateToLocalDateTime

import org.threeten.bp.LocalDateTime; //导入方法依赖的package包/类
@Test
public void correctDateToLocalDateTime() {
  LocalDateTime expectedLocalDateTime = LocalDateTime.of(2017, Month.APRIL, 10, 10, 10, 10);
  Calendar calendar = Calendar.getInstance();
  calendar.set(2017, Calendar.APRIL, 10, 10, 10, 10);
  calendar.set(Calendar.MILLISECOND, 0);
  Date actualDate = calendar.getTime();

  LocalDateTime actualLocalDate = DateHelper.dateToLocalDateTime(actualDate);
  assertThat(actualLocalDate, equalTo(expectedLocalDateTime));
}
 
开发者ID:xmartlabs,项目名称:bigbang,代码行数:12,代码来源:DateHelperTest.java

示例10: setBeginDate

import org.threeten.bp.LocalDateTime; //导入方法依赖的package包/类
public void setBeginDate(int year,int month,int day,int hour,int minute,int second)
{
    begin=LocalDateTime.of(year,month,day,hour,minute,second);
}
 
开发者ID:AndroidNewbies,项目名称:Sanxing,代码行数:5,代码来源:AbstractsxObject.java

示例11: setEndDate

import org.threeten.bp.LocalDateTime; //导入方法依赖的package包/类
public void setEndDate(int year,int month,int day,int hour,int minute,int second)
{
    end = LocalDateTime.of(year, month, day, hour, minute, second);
}
 
开发者ID:AndroidNewbies,项目名称:Sanxing,代码行数:5,代码来源:AbstractsxObject.java

示例12: isSameDayNormal

import org.threeten.bp.LocalDateTime; //导入方法依赖的package包/类
@Test
public void isSameDayNormal() {
  LocalDateTime endDate = LocalDateTime.of(2017, Month.APRIL, 10, 15, 0, 0);
  boolean actual = DateHelper.isSameDayIncludingMidnight(LOCAL_DATE_TIME_MONDAY_APRIL_10TH_10_HRS, endDate);
  assertThat(actual, is(true));
}
 
开发者ID:xmartlabs,项目名称:bigbang,代码行数:7,代码来源:DateHelperTest.java

示例13: isSameDayExtremes

import org.threeten.bp.LocalDateTime; //导入方法依赖的package包/类
@Test
public void isSameDayExtremes() {
  LocalDateTime actualDate = LocalDateTime.of(2017, Month.APRIL, 10, 23, 59, 59);
  boolean actual = DateHelper.isSameDayIncludingMidnight(LOCAL_DATE_TIME_MONDAY_APRIL_10TH_10_HRS, actualDate);
  assertThat(actual, is(true));
}
 
开发者ID:xmartlabs,项目名称:bigbang,代码行数:7,代码来源:DateHelperTest.java

示例14: isSameDayLatest

import org.threeten.bp.LocalDateTime; //导入方法依赖的package包/类
@Test
public void isSameDayLatest() {
  LocalDateTime actualDate = LocalDateTime.of(2017, Month.APRIL, 10, 23, 59, 59);
  boolean actual = DateHelper.isSameDayIncludingMidnight(LOCAL_DATE_TIME_MONDAY_APRIL_10TH_10_HRS, actualDate);
  assertThat(actual, is(true));
}
 
开发者ID:xmartlabs,项目名称:bigbang,代码行数:7,代码来源:DateHelperTest.java

示例15: isSameDayIncludingMidnight

import org.threeten.bp.LocalDateTime; //导入方法依赖的package包/类
@Test
public void isSameDayIncludingMidnight() {
  LocalDateTime actualDate = LocalDateTime.of(2017, Month.APRIL, 11, 0, 0, 0);
  boolean actual = DateHelper.isSameDayIncludingMidnight(LOCAL_DATE_TIME_MONDAY_APRIL_10TH_10_HRS, actualDate);
  assertThat(actual, is(true));
}
 
开发者ID:xmartlabs,项目名称:bigbang,代码行数:7,代码来源:DateHelperTest.java


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