當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。