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


Java DateTime.toDate方法代码示例

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


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

示例1: deserialize

import org.joda.time.DateTime; //导入方法依赖的package包/类
@Override
public Date deserialize(JsonParser gen, DeserializationContext ctxt) throws IOException, JsonProcessingException {
    String date = gen.getText();

    if (StringUtils.isEmpty(date)) {
        return null;
    }

    if (StringUtils.isNumeric(date)) {
        return new Date(Long.valueOf(date));
    }
    try {
        DateTime dt = fmt.parseDateTime(date);
        return dt.toDate();
    } catch (Exception e) {
        throw new IOException(e);
    }
}
 
开发者ID:linuer,项目名称:nan,代码行数:19,代码来源:FDateJsonDeserializer.java

示例2: main

import org.joda.time.DateTime; //导入方法依赖的package包/类
public static void main(String[] args) {
       DateTime startTime = new DateTime(new Date());
       Long startTimeLong = startTime.minusDays(1).withTime(0, 0, 0, 0).toDate().getTime();
       Long endTimeLong = new DateTime(startTime).withTime(0, 0, 0, 0).toDate().getTime();
       
	System.out.println("startTime:"+startTime);
	
	
       DateTime startTime2 = new DateTime(new Date());
       startTime2 = startTime2.minusDays(0).withTime(0, 0, 0, 0);
       DateTime endTime2 = new DateTime(startTime).minusDays(0).withTime(23, 59, 59, 999);
       
       Date start = startTime2.toDate();
       Date end = endTime2.toDate();
       System.out.println("start:"+start);
       if (start.getTime() >= startTimeLong && end.getTime() < endTimeLong) {
           System.out.println("ok");
       }
       if (start.getTime() >= endTimeLong) {
           System.out.println("not ok");
       }
       Date old = new Date();
       Date plus1 = new DateTime(old).plusSeconds(1).toDate();
       System.out.println(1000.0 / (plus1.getTime() - old.getTime()));
}
 
开发者ID:alamby,项目名称:upgradeToy,代码行数:26,代码来源:DateUtils.java

示例3: getFirstDayOfWeek

import org.joda.time.DateTime; //导入方法依赖的package包/类
/**
 * 获取某一天所在周的周一
 * 
 * @param date
 * @return
 */
public static Date getFirstDayOfWeek(Date date) {
	DateTime dateTime = new DateTime(date.getTime());
	int dayOfWeek = dateTime.getDayOfWeek();
	DateTime firstDate = dateTime.minusDays(dayOfWeek - 1);
	firstDate = firstDate.withTime(0, 0, 0, 0);
	return firstDate.toDate();

}
 
开发者ID:alamby,项目名称:upgradeToy,代码行数:15,代码来源:DateUtils.java

示例4: getFirstDayOfYear

import org.joda.time.DateTime; //导入方法依赖的package包/类
/**
 * 获取某一天所在年的第一天
 * 
 * @param date
 * @return
 */
public static Date getFirstDayOfYear(Date date) {
	DateTime dateTime = new DateTime(date.getTime());
	int dayOfYear = dateTime.getDayOfYear();
	DateTime firstDate = dateTime.minusDays(dayOfYear - 1);
	firstDate = firstDate.withTime(0, 0, 0, 0);
	return firstDate.toDate();

}
 
开发者ID:alamby,项目名称:upgradeToy,代码行数:15,代码来源:DateUtils.java

示例5: getLastOfDay

import org.joda.time.DateTime; //导入方法依赖的package包/类
/**
 * 获取某一天最后时间
 * 
 * @param date
 * @return
 */
public static Date getLastOfDay(Date date) {
	DateTime dateTime = new DateTime(date.getTime());
	dateTime = dateTime.withTime(23, 59, 59, 0);
	return dateTime.toDate();

}
 
开发者ID:alamby,项目名称:upgradeToy,代码行数:13,代码来源:DateUtils.java

示例6: parse

import org.joda.time.DateTime; //导入方法依赖的package包/类
/**
 * 按照指定格式匹配解析字符串为日期
 *
 * @param dateStr
 * @param pattern
 * @return
 */
public static Date parse(@NotNull String dateStr, @NotNull String pattern) {
    Objects.requireNonNull(dateStr, "data string must not null");
    Objects.requireNonNull(pattern, "date pattern must not null");
    DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern(pattern);
    DateTime dateTime = dateTimeFormatter.parseDateTime(dateStr);
    return dateTime.toDate();
}
 
开发者ID:AsuraTeam,项目名称:asura,代码行数:15,代码来源:DateParser.java

示例7: getLastDayOfWeek

import org.joda.time.DateTime; //导入方法依赖的package包/类
/**
 * 获取某一天所在周的周日
 * 
 * @param date
 * @return
 */
public static Date getLastDayOfWeek(Date date) {
	DateTime dateTime = new DateTime(date.getTime());
	int dayOfWeek = dateTime.getDayOfWeek();

	DateTime theDateTime = new DateTime(date.getTime());
	theDateTime = theDateTime.plusDays(7 - dayOfWeek);
	return theDateTime.toDate();
}
 
开发者ID:alamby,项目名称:upgradeToy,代码行数:15,代码来源:TimeUtils.java

示例8: testGetPublishIdToSnapshotFrom

import org.joda.time.DateTime; //导入方法依赖的package包/类
@Test
public void testGetPublishIdToSnapshotFrom() throws Exception {
    String excludeInstanceId = "exclude-352768";
    List<String> instanceIds = new ArrayList<>();
    instanceIds.add(excludeInstanceId);
    instanceIds.add(instanceId);
    instanceIds.add("extra-89351");

    Date dt = new Date();

    DateTime originalDateTime = new DateTime(dt);
    Date originalDate = originalDateTime.toDate();
    DateTime originalPlusOneDateTime = originalDateTime.plusDays(1);
    Date originalPlusOneDate = originalPlusOneDateTime.toDate();

    when(awsHelperService.getInstanceIdsForAutoScalingGroup(
        envValues.getAutoScaleGroupNameForPublish())).thenReturn(instanceIds);

    Map<String, String> instanceTags1 = new HashMap<>();
    instanceTags1.put(InstanceTags.SNAPSHOT_ID.getTagName(), "");

    when(awsHelperService.getTags(anyString())).thenReturn(instanceTags1);

    when(awsHelperService.getLaunchTime(instanceId)).thenReturn(originalDate);
    when(awsHelperService.getLaunchTime("extra-89351")).thenReturn(originalPlusOneDate);

    when(httpUtil.isHttpGetResponseOk(anyString())).thenReturn(true);
    
    String resultInstanceId = aemHelperService.getPublishIdToSnapshotFrom(excludeInstanceId);
    
    assertThat(resultInstanceId, equalTo(instanceId));
}
 
开发者ID:shinesolutions,项目名称:aem-orchestrator,代码行数:33,代码来源:AemInstanceHelperServiceTest.java

示例9: strToDate

import org.joda.time.DateTime; //导入方法依赖的package包/类
public static Date strToDate(String dateTimeStr, String formatStr) {
    DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern(formatStr);
    DateTime dateTime = dateTimeFormatter.parseDateTime(dateTimeStr);
    return dateTime.toDate();
}
 
开发者ID:jeikerxiao,项目名称:X-mall,代码行数:6,代码来源:DateTimeUtil.java

示例10: safeDate

import org.joda.time.DateTime; //导入方法依赖的package包/类
private Date safeDate(DateTime dateTime) {
    return dateTime == null ? null : dateTime.toDate();
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:4,代码来源:TaskNode.java

示例11: convert

import org.joda.time.DateTime; //导入方法依赖的package包/类
@Override
public Date convert(DateTime source) {
	return source.toDate();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:5,代码来源:JodaTimeConverters.java

示例12: setLastModifiedDate

import org.joda.time.DateTime; //导入方法依赖的package包/类
public void setLastModifiedDate(final DateTime lastModifiedDate) {
    this.lastModifiedDate = null == lastModifiedDate ? null : lastModifiedDate.toDate();
}
 
开发者ID:geeker-lait,项目名称:tasfe-framework,代码行数:4,代码来源:BaseAuditableEntity.java

示例13: strToDate

import org.joda.time.DateTime; //导入方法依赖的package包/类
public static Date strToDate(String dateTimeStr,String formatStr){
    DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern(formatStr);
    DateTime dateTime = dateTimeFormatter.parseDateTime(dateTimeStr);
    return dateTime.toDate();
}
 
开发者ID:prb8025236,项目名称:CheapStore,代码行数:6,代码来源:DateTimeUtil.java

示例14: date

import org.joda.time.DateTime; //导入方法依赖的package包/类
private Date date(DateTime dateTime) {
    return dateTime.toDate();
}
 
开发者ID:monPlan,项目名称:springboot-spwa-gae-demo,代码行数:4,代码来源:DateToStringTest.java

示例15: getDayOfWeek

import org.joda.time.DateTime; //导入方法依赖的package包/类
/**
 * 获取指定日期当周的任意一天
 *
 *
 * @param date 指定日期为标准
 * @param week 偏移周数,正数:往后指定周数量,负数:往前指定周数量
 * @param dayOfWeek 指定天数 1第一天周一 7最后一天为周日
 * @return
 */
public static Date getDayOfWeek(@NotNull Date date, int week, int dayOfWeek) {
    Objects.requireNonNull(date, "date must not null");
    DateTime dateTime = new DateTime(date);
    dateTime = dateTime.plusWeeks(week).withDayOfWeek(dayOfWeek);
    return dateTime.toDate();
}
 
开发者ID:AsuraTeam,项目名称:asura,代码行数:16,代码来源:DateCalculator.java


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