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


Java GregorianCalendar.getTimeInMillis方法代码示例

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


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

示例1: getYearlessMillis

import java.util.GregorianCalendar; //导入方法依赖的package包/类
/**
 * Antaa millisekuntiajan ilman vuositietoa. Alusta poistetaan nollat jos niitä on.<br/>
 * <b>Poistettu käytöstä, koska testatessa ilmeni ongelmia. Parempi käyttää vain timestampia 'as is'.</b><br/>
 * (Katsotaan ehkä joskus myöhemmin, mikäli käytössä olisi mitään järkeä.)
 *
 * @param millis
 *            Millisekuntiaika, jota käytetään pohjana sekvenssiarvon generoimiseen
 * @return Millisekunnit ilman vuosia
 * @deprecated
 */
@Deprecated
protected String getYearlessMillis(long millis) {

    GregorianCalendar gregZero = new GregorianCalendar();
    gregZero.setTimeInMillis(millis);
    gregZero.set(Calendar.MONTH, 0);
    gregZero.set(Calendar.DAY_OF_MONTH, 1);
    gregZero.set(Calendar.HOUR_OF_DAY, 0);
    gregZero.set(Calendar.MINUTE, 0);
    gregZero.set(Calendar.SECOND, 0);
    gregZero.set(Calendar.MILLISECOND, 0);
    long alteredMillis = gregZero.getTimeInMillis();

    return Long.toString(millis - alteredMillis).substring(0, 3);
}
 
开发者ID:TheFinnishSocialInsuranceInstitution,项目名称:KantaCDA-API,代码行数:26,代码来源:OidGenerator.java

示例2: getCountDaysBetweenDates

import java.util.GregorianCalendar; //导入方法依赖的package包/类
public static Integer getCountDaysBetweenDates(Date d1, Date d2) {
	GregorianCalendar dataInicio = new GregorianCalendar();
	dataInicio.setTime(d1);
	dataInicio.set(Calendar.AM_PM, Calendar.AM);
	dataInicio.set(Calendar.HOUR, 0);
	dataInicio.set(Calendar.MINUTE, 0);
	dataInicio.set(Calendar.SECOND, 0);
	dataInicio.set(Calendar.MILLISECOND, 0);

	GregorianCalendar dataFim = new GregorianCalendar();
	dataFim.setTime(d2);
	dataFim.set(Calendar.AM_PM, Calendar.AM);
	dataFim.set(Calendar.HOUR, 0);
	dataFim.set(Calendar.MINUTE, 0);
	dataFim.set(Calendar.SECOND, 0);
	dataFim.set(Calendar.MILLISECOND, 0);

	if (dataFim.get(Calendar.YEAR) > dataInicio.get(Calendar.DAY_OF_YEAR)) {
		long diffMillis = dataFim.getTimeInMillis() - dataInicio.getTimeInMillis();
		long diffDays = diffMillis / (24 * 60 * 60 * 1000);
		return Long.valueOf(diffDays).intValue();
	}
	return 0;
}
 
开发者ID:edylle,项目名称:hockey-game,代码行数:25,代码来源:DateUtils.java

示例3: scheduleNextLindviorDate

import java.util.GregorianCalendar; //导入方法依赖的package包/类
protected long scheduleNextLindviorDate()
{
	final GregorianCalendar date = new GregorianCalendar();
	date.set(Calendar.MINUTE, RESET_MIN);
	date.set(Calendar.HOUR_OF_DAY, RESET_HOUR);
	if (System.currentTimeMillis() >= date.getTimeInMillis())
	{
		date.add(Calendar.DAY_OF_WEEK, 1);
	}
	
	final int dayOfWeek = date.get(Calendar.DAY_OF_WEEK);
	if (dayOfWeek <= RESET_DAY_1)
	{
		date.add(Calendar.DAY_OF_WEEK, RESET_DAY_1 - dayOfWeek);
	}
	else if (dayOfWeek <= RESET_DAY_2)
	{
		date.add(Calendar.DAY_OF_WEEK, RESET_DAY_2 - dayOfWeek);
	}
	else
	{
		date.add(Calendar.DAY_OF_WEEK, 1 + RESET_DAY_1);
	}
	return date.getTimeInMillis() - System.currentTimeMillis();
}
 
开发者ID:rubenswagner,项目名称:L2J-Global,代码行数:26,代码来源:Lindvior.java

示例4: testBug7686

import java.util.GregorianCalendar; //导入方法依赖的package包/类
public void testBug7686() throws SQLException {
    String tableName = "testBug7686";
    createTable(tableName, "(id1 int(10) unsigned NOT NULL, id2 DATETIME, field1 varchar(128) NOT NULL default '', PRIMARY KEY  (id1, id2))", "InnoDB;");

    this.stmt.executeUpdate("insert into " + tableName + " (id1, id2, field1) values (1, '2005-01-05 13:59:20', 'foo')");

    String sQuery = " SELECT * FROM " + tableName + " WHERE id1 = ? AND id2 = ?";
    this.pstmt = this.conn.prepareStatement(sQuery, ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);

    this.conn.setAutoCommit(false);
    this.pstmt.setInt(1, 1);
    GregorianCalendar cal = new GregorianCalendar();
    cal.clear();
    cal.set(2005, 00, 05, 13, 59, 20);

    Timestamp jan5before2pm = null;
    jan5before2pm = new java.sql.Timestamp(cal.getTimeInMillis());

    this.pstmt.setTimestamp(2, jan5before2pm);
    this.rs = this.pstmt.executeQuery();
    assertTrue(this.rs.next());
    this.rs.absolute(1);
    this.rs.updateString("field1", "bar");
    this.rs.updateRow();
    this.conn.commit();
    this.conn.setAutoCommit(true);

}
 
开发者ID:rafallis,项目名称:BibliotecaPS,代码行数:29,代码来源:ResultSetRegressionTest.java

示例5: set

import java.util.GregorianCalendar; //导入方法依赖的package包/类
public void  set( GregorianCalendar base, GregorianCalendar now ){
    int       offset; 

    offset = (int)(now.getTimeInMillis() - base.getTimeInMillis()) / wheelConfig.getWheelSize(); // convert based on wheel resolution
    cycles = offset / wheelConfig.getWheelSize();
    index = offset % wheelConfig.getWheelSize();
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:8,代码来源:WheelTime.java

示例6: DateGenerator

import java.util.GregorianCalendar; //导入方法依赖的package包/类
public DateGenerator(GregorianCalendar from, Integer toSpanInDays, Long seed)
{
    this.from = from.getTimeInMillis();
    this.to = this.from + oneDayInMillis*toSpanInDays;

    ranGen = new Random(seed);
}
 
开发者ID:SmartDataAnalytics,项目名称:Embeddable-BSBM,代码行数:8,代码来源:DateGenerator.java

示例7: main

import java.util.GregorianCalendar; //导入方法依赖的package包/类
/**
 * Some test code.
 * 
 * @param args  ignored.
 */
public static void main(String[] args) {
    GregorianCalendar c0 = new GregorianCalendar(2006, 10, 1, 0, 0, 0);
    GregorianCalendar c1 = new GregorianCalendar(2006, 10, 1, 11, 37, 43);
    c1.set(Calendar.MILLISECOND, 123);
    
    System.out.println("Default: ");
    RelativeDateFormat rdf = new RelativeDateFormat(c0.getTimeInMillis());
    System.out.println(rdf.format(c1.getTime()));
    System.out.println();
    
    System.out.println("Hide milliseconds: ");
    rdf.setSecondFormatter(new DecimalFormat("0"));
    System.out.println(rdf.format(c1.getTime()));        
    System.out.println();

    System.out.println("Show zero day output: ");
    rdf.setShowZeroDays(true);
    System.out.println(rdf.format(c1.getTime()));
    System.out.println();
    
    System.out.println("Alternative suffixes: ");
    rdf.setShowZeroDays(false);
    rdf.setDaySuffix(":");
    rdf.setHourSuffix(":");
    rdf.setMinuteSuffix(":");
    rdf.setSecondSuffix("");
    System.out.println(rdf.format(c1.getTime()));
    System.out.println();
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:35,代码来源:RelativeDateFormat.java

示例8: dateToJulian

import java.util.GregorianCalendar; //导入方法依赖的package包/类
public static long dateToJulian(Date date) {

        GregorianCalendar calendarDate = new GregorianCalendar();
        calendarDate.setTime(date);

        Calendar calendarBegin = new GregorianCalendar(1, GregorianCalendar.JANUARY, 1);

        long millisecondsDate = calendarDate.getTimeInMillis();
        long millisecondsBegin = calendarBegin.getTimeInMillis();
        long diff = millisecondsDate - millisecondsBegin;
        long diffDays = diff / (24 * 60 * 60 * 1000) - 1;

        return diffDays;
    }
 
开发者ID:monsieurh,项目名称:homebank_android,代码行数:15,代码来源:HbCompat.java

示例9: randomDateInMillis

import java.util.GregorianCalendar; //导入方法依赖的package包/类
public Long randomDateInMillis(Long from, Long to)
{
    long date = (long)(ranGen.nextDouble()*(to-from)+from);
    GregorianCalendar gc = new GregorianCalendar();
    gc.setTime(new Date(date));

    return gc.getTimeInMillis();
}
 
开发者ID:SmartDataAnalytics,项目名称:Embeddable-BSBM,代码行数:9,代码来源:DateGenerator.java

示例10: PostLimitOrder

import java.util.GregorianCalendar; //导入方法依赖的package包/类
public void  PostLimitOrder( TTradeRequest tradeRequest ){
    TradeType            eTradeType;
    double      CurrentPrice = -1.0;
    TTickerEntry    pNewEntry = new TTickerEntry();

    eTradeType = ConvertTradeTypeIdToEnum(tradeRequest.trade_type_id.toCharArray());

    pNewEntry.price_quote = tradeRequest.price_quote;
    pNewEntry.symbol = new String(tradeRequest.symbol);
    pNewEntry.trade_qty = LIMIT_TRIGGER_TRADE_QTY;

    CurrentPrice = priceBoard.getCurrentPrice( tradeRequest.symbol ).getDollars();

    if((( eTradeType == TradeType.eLimitBuy || eTradeType == TradeType.eStopLoss ) &&
            CurrentPrice <= tradeRequest.price_quote )
        ||
            (( eTradeType == TradeType.eLimitSell ) &&
            CurrentPrice >= tradeRequest.price_quote )){
        pNewEntry.price_quote = CurrentPrice;
        limitOrderTimers.processExpiredTimers();
        inTheMoneyLimitOrderQ.add(pNewEntry);
    }
    else{
        pNewEntry.price_quote = tradeRequest.price_quote;
        double TriggerTimeDelay;
        GregorianCalendar currGreTime = new GregorianCalendar();
        GregorianCalendar baseGreTime = new GregorianCalendar();
        currGreTime.setTime(currentTime);
        baseGreTime.setTime(baseTime);
        double fCurrentTime = currGreTime.getTimeInMillis() - baseGreTime.getTimeInMillis();
        //TODO the third para, compare to c++
        TriggerTimeDelay = priceBoard.getSubmissionTime(pNewEntry.symbol, fCurrentTime, new EGenMoney(pNewEntry.price_quote), eTradeType) - fCurrentTime;
        limitOrderTimers.startTimer( TriggerTimeDelay);
    }
}
 
开发者ID:s-store,项目名称:s-store,代码行数:36,代码来源:MEETickerTape.java

示例11: marshal

import java.util.GregorianCalendar; //导入方法依赖的package包/类
@Override
public void marshal(final Object source, final HierarchicalStreamWriter writer, final MarshallingContext context) {
    final GregorianCalendar calendar = (GregorianCalendar)source;
    ExtendedHierarchicalStreamWriterHelper.startNode(writer, "time", long.class);
    final long timeInMillis = calendar.getTimeInMillis();
    writer.setValue(String.valueOf(timeInMillis));
    writer.endNode();
    ExtendedHierarchicalStreamWriterHelper.startNode(writer, "timezone", String.class);
    writer.setValue(calendar.getTimeZone().getID());
    writer.endNode();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:GregorianCalendarConverter.java

示例12: getJulianDay

import java.util.GregorianCalendar; //导入方法依赖的package包/类
/**
 * Get julian day by unix timestamp
 * @param mills
 * @return
 */
public static double getJulianDay(long mills) {
    GregorianCalendar calendar = new GregorianCalendar();
    calendar.setTimeInMillis(mills);

    int year;
    int month;
    float day;

    int b = 0;
    double fraction;
    fraction = (calendar.get(Calendar.HOUR_OF_DAY) / 0.000024 + calendar.get(Calendar.MINUTE) / 0.001440);

    DecimalFormat decimalFormat = new DecimalFormat("0");
    day = calendar.get(Calendar.DAY_OF_MONTH);
    day = Float.parseFloat(decimalFormat.format(day) + "." + decimalFormat.format(Math.round(fraction)));
    year = calendar.get(Calendar.YEAR);
    month = calendar.get(Calendar.MONTH) + 1;

    if (month < 3) {
        year--;
        month += 12;
    }
    if (calendar.getTimeInMillis() - calendar.getGregorianChange().getTime() > 0) {
        int a = year / 100;
        b = 2 - a + a / 4;
    }

    double julianDay;
    julianDay = Math.floor(365.25 * year) + Math.floor(30.6001 * (month + 1)) + day + 1720994.5 + b;
    return julianDay;
}
 
开发者ID:helenepang,项目名称:LimitedDatePicker,代码行数:37,代码来源:CalendarDateUtils.java

示例13: generateRandomIatDateInPast

import java.util.GregorianCalendar; //导入方法依赖的package包/类
public static Date generateRandomIatDateInPast() {
    GregorianCalendar gc = new GregorianCalendar();
    int year = randBetween(1900, 2010);
    gc.set(gc.YEAR, year);
    int dayOfYear = randBetween(1, gc.getActualMaximum(gc.DAY_OF_YEAR));
    gc.set(gc.DAY_OF_YEAR, dayOfYear);

    return new Date(gc.getTimeInMillis());
}
 
开发者ID:GJWT,项目名称:javaOIDCMsg,代码行数:10,代码来源:TimeUtil.java

示例14: timeSpanToString

import java.util.GregorianCalendar; //导入方法依赖的package包/类
public static final String timeSpanToString(GregorianCalendar startGc, GregorianCalendar stopGc) {
	long millis = stopGc.getTimeInMillis() - startGc.getTimeInMillis();
	return millis / 60000 + " minutes";
}
 
开发者ID:shenan4321,项目名称:BIMplatform,代码行数:5,代码来源:Formatters.java

示例15: getDate

import java.util.GregorianCalendar; //导入方法依赖的package包/类
public static LogicalExpression getDate(GregorianCalendar date) {
  return new org.apache.drill.common.expression.ValueExpressions.DateExpression(date.getTimeInMillis());
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:4,代码来源:ValueExpressions.java


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