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


Java LocalDateTime.now方法代码示例

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


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

示例1: main

import java.time.LocalDateTime; //导入方法依赖的package包/类
public static void main(String[] args) {
    final LocalDateTime start = LocalDateTime.now();
    final Array<LocalDateTime> rowKeys = Range.of(start, start.plusSeconds(10000000), Duration.ofSeconds(1)).toArray().shuffle(1);
    final Array<String> colKeys = Array.of("A", "B", "C", "D");
    final DataFrame<LocalDateTime,String> frame = DataFrame.ofDoubles(rowKeys, colKeys).applyDoubles(v -> Math.random());
    for (int i=0; i<20; ++i) {
        frame.applyDoubles(v -> Math.random());
        final MyComparator comp = new MyComparator();
        final long t1 = System.nanoTime();
        //frame.rows().parallel().sort(true);
        frame.rows().parallel().sort(true);
        //frame.rows().parallel().sort(true, "A");
        final long t2 = System.nanoTime();
        System.out.println("Sorted DataFrame in " + ((t2-t1)/1000000) + " millis");
    }
}
 
开发者ID:zavtech,项目名称:morpheus-core,代码行数:17,代码来源:XDataFrameSorter.java

示例2: intercept

import java.time.LocalDateTime; //导入方法依赖的package包/类
@Override
public Object intercept(Invocation invocation) throws Throwable {
    MappedStatement mappedStatement = (MappedStatement) invocation.getArgs()[0];
    Object record = invocation.getArgs()[1];
    if (record instanceof TimeTraceable) {
        TimeTraceable timeTraceableRecord = (TimeTraceable) record;
        LocalDateTime now = LocalDateTime.now();
        if (mappedStatement.getSqlCommandType().equals(SqlCommandType.INSERT)) {
            timeTraceableRecord.setCreateTime(now);
        }
        timeTraceableRecord.setUpdateTime(now);
    } else if (record instanceof TimestampTraceable) {
        TimestampTraceable timestampTraceableRecord = (TimestampTraceable) record;
        long timestamp = Instant.now().getEpochSecond();
        if (mappedStatement.getSqlCommandType().equals(SqlCommandType.INSERT)) {
            timestampTraceableRecord.setCreateTime(timestamp);
        }
        timestampTraceableRecord.setUpdateTime(timestamp);
    }
    return invocation.proceed();
}
 
开发者ID:superkoh,项目名称:k-framework,代码行数:22,代码来源:TimeTraceInterceptor.java

示例3: timeInRaidspan

import java.time.LocalDateTime; //导入方法依赖的package包/类
@Test
public void timeInRaidspan() throws Exception {
    User user = mock(User.class);
    when(user.getName()).thenReturn("User");
    LocalDateTime localDateTime = LocalDateTime.now();
    LocalDateTime same = localDateTime;
    LocalDateTime before = localDateTime.minusMinutes(1);
    LocalDateTime after = localDateTime.plusMinutes(1);
    LocalDateTime end = localDateTime.plusMinutes(Utils.RAID_DURATION_IN_MINUTES);
    LocalDateTime sameAsEnd = end;
    LocalDateTime beforeEnd = end.minusMinutes(1);
    LocalDateTime afterEnd = end.plusMinutes(1);
    final LocaleService localeService = mock(LocaleService.class);
    when(localeService.getMessageFor(any(), any(), any())).thenReturn("Mupp");
    Raid raid = new Raid(pokemonRepository.getByName("Tyranitar"), end,
            new Gym("Test", "id", "10", "10", null),
            localeService, "Test");
    checkWhetherAssertFails(user, same, localeService, raid, false);
    checkWhetherAssertFails(user, after, localeService, raid, false);
    checkWhetherAssertFails(user, before, localeService, raid, true);
    checkWhetherAssertFails(user, sameAsEnd, localeService, raid, false);
    checkWhetherAssertFails(user, afterEnd, localeService, raid, true);
    checkWhetherAssertFails(user, beforeEnd, localeService, raid, false);
}
 
开发者ID:magnusmickelsson,项目名称:pokeraidbot,代码行数:25,代码来源:UtilsTest.java

示例4: formatLocalName

import java.time.LocalDateTime; //导入方法依赖的package包/类
@SideOnly(Side.CLIENT)
public String formatLocalName(Component sub) {
    LocalDateTime time = LocalDateTime.now();
    if(time.getMonth() == Month.APRIL && time.getDayOfMonth() == 1) {
        return "April Fools!";
    }

    String format = I18n.format(RandoresKeys.FORMAT);
    String name = this.getName();
    String compName = sub.getLocalName();
    return format.replace("${name}", name).replace("${item}", compName);
}
 
开发者ID:Randores,项目名称:Randores2,代码行数:13,代码来源:MaterialDefinition.java

示例5: testIfOverdue

import java.time.LocalDateTime; //导入方法依赖的package包/类
public void testIfOverdue(TestService testService, EventPublisher eventPublisher) {
  if (testService == null) {
    throw new IllegalArgumentException(("TestService must be set."));
  }
  TestResult lastTestResult = testResults.peek();
  if (lastTestResult == null) {
    this.test(testService, eventPublisher);
  } else {
    LocalDateTime now = LocalDateTime.now();
    LocalDateTime targetTime = lastTestResult.dateTime().plus(interval.toMillis(), ChronoUnit.MILLIS);
    if (targetTime.isBefore(now)) {
      this.test(testService, eventPublisher);
    }
  }
}
 
开发者ID:chatbot-workshop,项目名称:java-messenger-watchdog,代码行数:16,代码来源:Website.java

示例6: ProcessModelImpl

import java.time.LocalDateTime; //导入方法依赖的package包/类
ProcessModelImpl(final String name, final String description, final ProcessModelState state,
    final List<SubjectModelImpl> subjectModels, final SubjectModelImpl starterSubject,
    final float version) {
  this.name = name;
  this.description = description;
  this.createdAt = LocalDateTime.now();
  this.state = state;
  this.subjectModels = subjectModels;
  this.starterSubject = starterSubject;
  this.version = version;
}
 
开发者ID:stefanstaniAIM,项目名称:IPPR2016,代码行数:12,代码来源:ProcessModelImpl.java

示例7: starting

import java.time.LocalDateTime; //导入方法依赖的package包/类
@Override
protected void starting(Description description) {
    LocalDateTime now = LocalDateTime.now();

    time.set(now.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli());

    System.out.println("#######################################");
    System.out.println("# Starting: " + description.getDisplayName() + " [start-time=" + TIMESTAMP_FORMAT.format(now) + ']');
    System.out.println("#--------------------------------------");
}
 
开发者ID:hekate-io,项目名称:hekate,代码行数:11,代码来源:HekateTestBase.java

示例8: createApplicationHistory

import java.time.LocalDateTime; //导入方法依赖的package包/类
public static DrinkWaterApplicationHistory createApplicationHistory(DrinkWaterApplication app) {
    try {
        CustomJacksonObjectMapper mapper = new CustomJacksonObjectMapper();
        String config = mapper.writeValueAsString(app.configuration().getConfigurations());

        return new DrinkWaterApplicationHistory(LocalDateTime.now(), config, "noInfoNow");
    } catch (Exception e) {
        throw new RuntimeException("exception while serializing : be carrefull with MOCK objects, it can lead to infinite loops", e);
    }
}
 
开发者ID:drinkwater-io,项目名称:drinkwater-java,代码行数:11,代码来源:DrinkWaterApplicationHistory.java

示例9: testParallelStream

import java.time.LocalDateTime; //导入方法依赖的package包/类
/**
 * 使用并行流
 * channel=127, sum amount=2999937
 * channel=128, sum amount=2999940
 * channel=129, sum amount=2999940
 * channel=130, sum amount=2999940
 * channel=131, sum amount=2999940
 * cost time:440
 */
@Test
public void testParallelStream() {
    List<Order> list = Lists.newArrayList();

    for (int i = 0; i < size; i++) {
        Order o = new Order(i, "success", 3, i % 5 + 127, "12112121223", "jim", "18612534462", LocalDateTime.now().minusDays(12), LocalDateTime.now());
        list.add(o);
    }

    Instant start = Instant.now();

    list.parallelStream().collect(Collectors.groupingBy(Order::getChannelId)).entrySet()
            .parallelStream()
            .collect(Collectors.toMap(Map.Entry::getKey, element -> element.getValue()
                    .parallelStream()
                    .filter(order -> order.getOrderId() > 100)
                    .filter(order -> order.getUserName().equals("jim"))
                    .collect(Collectors.summingLong(Order::getAmount))))
            .entrySet()
            .forEach(data -> {
                System.out.println("channel=" + data.getKey() + ", sum amount=" + data.getValue());
            });

    Instant end = Instant.now();
    long millis = Duration.between(start, end).toMillis();
    System.out.println("cost time:" + millis);
}
 
开发者ID:cbooy,项目名称:cakes,代码行数:37,代码来源:PerformanceTest4Business.java

示例10: Quiz

import java.time.LocalDateTime; //导入方法依赖的package包/类
/**
 * 
 * @param quizTitle
 * @param topic
 * @param questions
 * @param creatorId
 * @param maxScore
 */
public Quiz(String quizTitle, String topic, List<QuizQuestion> questions, 
		String creatorId, int maxScore) {
	super();
	this.quizTitle = quizTitle;
	this.topic = topic;
	this.questions = questions;
	this.creatorId = creatorId;
	this.createdOn = LocalDateTime.now();
	this.maxScore = maxScore;
}
 
开发者ID:grantleymorrison,项目名称:FlashBoard,代码行数:19,代码来源:Quiz.java

示例11: getPicturesSince

import java.time.LocalDateTime; //导入方法依赖的package包/类
@GET
@Path("/")
@Produces(MediaType.APPLICATION_JSON)
public List<String> getPicturesSince(){
    final LocalDateTime now = LocalDateTime.now();
    final List<String> times = Arrays.asList(String.valueOf(now));
    return times;
}
 
开发者ID:erikcostlow,项目名称:PiCameraProject,代码行数:9,代码来源:BasicRest.java

示例12: dateTimeNow

import java.time.LocalDateTime; //导入方法依赖的package包/类
public static String dateTimeNow() {
    DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
    LocalDateTime dateTime = LocalDateTime.now();
    String formattedDateTime = dateTime.format(formatter) + ": ";
    return formattedDateTime;
}
 
开发者ID:polygOnetic,项目名称:guetzliconverter,代码行数:7,代码来源:GuetzliConverter.java

示例13: isAprilFools

import java.time.LocalDateTime; //导入方法依赖的package包/类
public static boolean isAprilFools() {
	LocalDateTime now = LocalDateTime.now();
	return now.getDayOfMonth()==1 && now.getMonth()==Month.APRIL;
}
 
开发者ID:elytra,项目名称:Thermionics,代码行数:5,代码来源:Thermionics.java

示例14: ReceiveSubmission

import java.time.LocalDateTime; //导入方法依赖的package包/类
ReceiveSubmission() {
  this.submissionState = SubmissionState.TO_RECEIVE;
  this.createdAt = LocalDateTime.now();
}
 
开发者ID:stefanstaniAIM,项目名称:IPPR2016,代码行数:5,代码来源:ReceiveSubmission.java

示例15: testClacPlus

import java.time.LocalDateTime; //导入方法依赖的package包/类
/**
 * 时间运算,计算完成后会返回新的对象,并不会改变原来的时间
 */
@Test
public void testClacPlus() {
    LocalDateTime ldt = LocalDateTime.now();

    System.out.println(ldt);

    // 加: 天
    LocalDateTime day = ldt.plusDays(1);
    System.out.println("day: " + day);

    // 加: 小时
    LocalDateTime hours = ldt.plusHours(1);
    System.out.println("hours: " + hours);

    // 加: 分钟
    LocalDateTime minutes = ldt.plusMinutes(1);
    System.out.println("minutes: " + minutes);

    // 加: 月
    LocalDateTime months = ldt.plusMonths(1);
    System.out.println("months: " + months);

    // 加: 纳秒
    LocalDateTime nanos = ldt.plusNanos(1);
    System.out.println("nanos: " + nanos);

    // 加: 秒
    LocalDateTime seconds = ldt.plusSeconds(1);
    System.out.println("seconds: " + seconds);

    // 加: 周
    LocalDateTime weeks = ldt.plusWeeks(1);
    System.out.println("weeks: " + weeks);

    // 加: 年
    LocalDateTime years = ldt.plusYears(1);
    System.out.println("years: " + years);

    System.out.println(ldt);
}
 
开发者ID:cbooy,项目名称:cakes,代码行数:44,代码来源:LocalDateTimeDemo.java


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