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


Java GregorianCalendar类代码示例

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


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

示例1: preparePeriod

import java.util.GregorianCalendar; //导入依赖的package包/类
private Period preparePeriod(long periodStartTime, long periodEndTime)
        throws DatatypeConfigurationException {

    Period period = new Period();

    DatatypeFactory df = DatatypeFactory.newInstance();
    GregorianCalendar gc = new GregorianCalendar();

    // start date
    period.setStartDate(BigInteger.valueOf(periodStartTime));
    gc.setTimeInMillis(periodStartTime);
    period.setStartDateIsoFormat(df.newXMLGregorianCalendar(gc).normalize());

    // end date
    period.setEndDate(BigInteger.valueOf(periodEndTime));
    gc.setTimeInMillis(periodEndTime);
    period.setEndDateIsoFormat(df.newXMLGregorianCalendar(gc).normalize());

    return period;
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:21,代码来源:ResellerShareResultAssembler.java

示例2: testFilteringBy

import java.util.GregorianCalendar; //导入依赖的package包/类
/**
 * There is no assert equals because everything depends of the user input.
 * If the user input a good data so, the programe keep runing, else, we created an exception.
 */
@Test
public void testFilteringBy() {
	GregorianCalendar date = new GregorianCalendar(2017, 8, 12, 22, 00, 10);
	EarthCoordinate earth = new EarthCoordinate(100.0, 34.0, 890.0);
	Wifi wifi = new Wifi(date, "easyId", earth, "easyName", "easyMac", 5000, -90);
	ArrayList<Wifi> array = new ArrayList<Wifi>();
	array.add(wifi);
	FilteringPlace filter = new FilteringPlace();
	try {
		filter.filteringBy(array);
	} 
	catch (InputException ex) {
		ex.printStackTrace();
	}
}
 
开发者ID:orelshalom,项目名称:Assignment_1,代码行数:20,代码来源:FilteringPlaceTest.java

示例3: createAdmin

import java.util.GregorianCalendar; //导入依赖的package包/类
private PlatformUser createAdmin(Organization cust) throws Exception {
    PlatformUser admin = new PlatformUser();
    admin.setAdditionalName("AddName Admin");
    admin.setAddress("Address");
    admin.setCreationDate(GregorianCalendar.getInstance().getTime());
    admin.setEmail("[email protected]");
    admin.setFirstName("FirstName");
    // create system wide unique userId
    admin.setUserId("admin_" + cust.getOrganizationId());
    admin.setLastName("LastName");
    admin.setPhone("111111/111111");
    admin.setStatus(UserAccountStatus.ACTIVE);
    admin.setOrganization(cust);
    admin.setLocale("en");
    mgr.persist(admin);
    PlatformUsers.grantAdminRole(mgr, admin);
    mgr.flush();
    return admin;
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:20,代码来源:SubscriptionServiceBeanDirectLoginIT.java

示例4: fastDateCreate

import java.util.GregorianCalendar; //导入依赖的package包/类
final static Date fastDateCreate(int year, int month, int day, Calendar targetCalendar) {

        Calendar dateCal = (targetCalendar == null) ? new GregorianCalendar() : targetCalendar;

        synchronized (dateCal) {
            java.util.Date origCalDate = dateCal.getTime();
            try {
                dateCal.clear();

                // why-oh-why is this different than java.util.date, in the year part, but it still keeps the silly '0' for the start month????
                dateCal.set(year, month - 1, day, 0, 0, 0);
                dateCal.set(Calendar.MILLISECOND, 0);

                long dateAsMillis = dateCal.getTimeInMillis();

                return new Date(dateAsMillis);
            } finally {
                dateCal.setTime(origCalDate);
            }
        }
    }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:TimeUtil.java

示例5: testGetLastMillisecondWithCalendar

import java.util.GregorianCalendar; //导入依赖的package包/类
/**
 * Some checks for the getLastMillisecond(TimeZone) method.
 */
public void testGetLastMillisecondWithCalendar() {
    Day d = new Day(4, 5, 2001);
    GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY);
    assertEquals(989017199999L, d.getLastMillisecond(calendar));
    
    // try null calendar
    boolean pass = false;
    try {
        d.getLastMillisecond((Calendar) null);
    }
    catch (NullPointerException e) {
        pass = true;
    }
    assertTrue(pass);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:19,代码来源:DayTests.java

示例6: testGetLastMillisecondWithCalendar

import java.util.GregorianCalendar; //导入依赖的package包/类
/**
 * Some checks for the getLastMillisecond(TimeZone) method.
 */
public void testGetLastMillisecondWithCalendar() {
    Week w = new Week(52, 2001);
    GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY);
    assertEquals(1009756799999L, w.getLastMillisecond(calendar));
    
    // try null calendar
    boolean pass = false;
    try {
        w.getLastMillisecond((Calendar) null);
    }
    catch (NullPointerException e) {
        pass = true;
    }
    assertTrue(pass);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:19,代码来源:WeekTests.java

示例7: getToday

import java.util.GregorianCalendar; //导入依赖的package包/类
Pair<Date, Date> getToday() {
    final GregorianCalendar today = new GregorianCalendar();
    today.set(Calendar.HOUR_OF_DAY, today.getActualMaximum(Calendar.HOUR_OF_DAY));
    today.set(Calendar.MINUTE, today.getActualMaximum(Calendar.MINUTE));
    today.set(Calendar.SECOND, today.getActualMaximum(Calendar.SECOND));
    today.set(Calendar.MILLISECOND, today.getActualMaximum(Calendar.MILLISECOND));

    final Date end = today.getTime();
    today.add(Calendar.DATE, -1);
    today.set(Calendar.HOUR_OF_DAY, 0);
    today.set(Calendar.MINUTE, 0);
    today.set(Calendar.SECOND, 0);
    today.set(Calendar.MILLISECOND, 0);

    return new Pair<>(today.getTime(), end);
}
 
开发者ID:PacktPublishing,项目名称:Hands-On-Android-UI-Development,代码行数:17,代码来源:AllowanceOverviewPresenter.java

示例8: out

import java.util.GregorianCalendar; //导入依赖的package包/类
public void out(String output) {
    if (listBool) {
        list.add("[" + sdateFormat.format(new GregorianCalendar().getTime()) + "] " + output);
    } else {
        writer.println("[" + sdateFormat.format(new GregorianCalendar().getTime()) + "] " + output);
    }
}
 
开发者ID:phweda,项目名称:MFM,代码行数:8,代码来源:Debug.java

示例9: setJavaCal

import java.util.GregorianCalendar; //导入依赖的package包/类
/**
 * convert the SIP Date of this structure to a Java Date.
 * SIP Dates are forced to be GMT. Stores the converted time
 * as a java Calendar class.
 */
private void setJavaCal() {
    javaCal =
        new GregorianCalendar(
            TimeZone.getTimeZone("GMT:0"),
            Locale.getDefault());
    if (year != -1)
        javaCal.set(Calendar.YEAR, year);
    if (day != -1)
        javaCal.set(Calendar.DAY_OF_MONTH, day);
    if (month != -1)
        javaCal.set(Calendar.MONTH, month);
    if (wkday != -1)
        javaCal.set(Calendar.DAY_OF_WEEK, wkday);
    if (hour != -1)
        javaCal.set(Calendar.HOUR, hour);
    if (minute != -1)
        javaCal.set(Calendar.MINUTE, minute);
    if (second != -1)
        javaCal.set(Calendar.SECOND, second);
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:26,代码来源:SIPDate.java

示例10: writeSalesOrder

import java.util.GregorianCalendar; //导入依赖的package包/类
static public String writeSalesOrder(Integer rowCount){
  	// prepare linses content 
  	List<String> lines = new ArrayList<String>();
  	for(int i = 0; i < rowCount; i++){
  		String product = "product " + i / 1000;
  		BigDecimal product_price = (new BigDecimal(i/1000)).multiply(new BigDecimal(100));
   	JSONObject salesOrder = SalesOrderHelper.createOneSalesOrderRow("1", "1", product, product_price.toString(), "1", "michael", "han", "1", "QAD", "1", "HP", "open", Long.toString(new GregorianCalendar().getTimeInMillis()), "001");
   	lines.add(salesOrder.toString());
  	}
  	
  	// prepare file system by a given filename
  	String fileName = "SalesOrder_" + rowCount.toString() + ".json";
  	String filePath = FileSystems.getDefault().getPath("").toAbsolutePath() + "/" + fileName;
  	File newFile = new File(filePath);
  	try {
	newFile.createNewFile();
} catch (IOException e) {
	e.printStackTrace();
}
  	FileWriterHelper.writeStringToFile(newFile.toPath(), lines, false);
  	
  	System.out.println("A json file with records[" + rowCount + "] :" + filePath);
  	return filePath;
  }
 
开发者ID:michael-hll,项目名称:BigQueryStudy,代码行数:25,代码来源:App.java

示例11: createObjectFromJson_dateAsStringTimeZone

import java.util.GregorianCalendar; //导入依赖的package包/类
@Test
public void createObjectFromJson_dateAsStringTimeZone() throws JSONException {
    // Oct 03 2015 14:45.33
    JSONObject json = new JSONObject();
    json.put("columnDate", "/Date(1443854733376+0800)/");

    realm.beginTransaction();
    realm.createObjectFromJson(AllTypes.class, json);
    realm.commitTransaction();

    AllTypes obj = realm.where(AllTypes.class).findFirst();
    Calendar cal = GregorianCalendar.getInstance();
    cal.setTimeZone(TimeZone.getTimeZone("Australia/West"));
    cal.set(2015, Calendar.OCTOBER, 03, 14, 45, 33);
    cal.set(Calendar.MILLISECOND, 376);
    Date convDate = obj.getColumnDate();

    assertEquals(convDate.getTime(), cal.getTimeInMillis());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:RealmJsonTests.java

示例12: dateToDateValue

import java.util.GregorianCalendar; //导入依赖的package包/类
static DateValue dateToDateValue(Date date, boolean midnightAsDate) {
    GregorianCalendar c = new GregorianCalendar(TimeUtils.utcTimezone());
    c.setTime(date);
    int h = c.get(Calendar.HOUR_OF_DAY),
            m = c.get(Calendar.MINUTE),
            s = c.get(Calendar.SECOND);
    if (midnightAsDate && 0 == (h | m | s)) {
        return new DateValueImpl(c.get(Calendar.YEAR),
                c.get(Calendar.MONTH) + 1,
                c.get(Calendar.DAY_OF_MONTH));
    } else {
        return new DateTimeValueImpl(c.get(Calendar.YEAR),
                c.get(Calendar.MONTH) + 1,
                c.get(Calendar.DAY_OF_MONTH),
                h,
                m,
                s);
    }
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:20,代码来源:DateIteratorFactory.java

示例13: generarPassword

import java.util.GregorianCalendar; //导入依赖的package包/类
private String generarPassword()
		throws NoSuchAlgorithmException, CitizenException {
	String password = "";
	Calendar calendar = GregorianCalendar.getInstance();
	Random r = new Random(calendar.getTimeInMillis());
	int i = 0;

	while (i < 10) {
		char c = (char) r.nextInt(255);
		if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z')
				|| (c >= 'a' && c <= 'z')) {
			password += c;
			i++;
		}
	}

	return new EncryptMD5().encrypting(password);
}
 
开发者ID:Arquisoft,项目名称:citizensLoader4b,代码行数:19,代码来源:Citizen.java

示例14: getTime

import java.util.GregorianCalendar; //导入依赖的package包/类
/**
   * @see net.sf.memoranda.Event#getTime()
   */
  public Date getTime() {
  	//Deprecated methods
//Date d = new Date();
//d.setHours(getHour());
//d.setMinutes(getMinute());
//d.setSeconds(0);
//End deprecated methods

Date d = new Date(); //Revision to fix deprecated methods (jcscoobyrs) 12-NOV-2003 14:26:00
Calendar calendar = new GregorianCalendar(Local.getCurrentLocale()); //Revision to fix deprecated methods (jcscoobyrs) 12-NOV-2003 14:26:00
calendar.setTime(d); //Revision to fix deprecated methods (jcscoobyrs) 12-NOV-2003 14:26:00
calendar.set(Calendar.HOUR_OF_DAY, getHour()); //Revision to fix deprecated methods (jcscoobyrs) 12-NOV-2003 14:26:00
calendar.set(Calendar.MINUTE, getMinute()); //Revision to fix deprecated methods (jcscoobyrs) 12-NOV-2003 14:26:00
calendar.set(Calendar.SECOND, 0); //Revision to fix deprecated methods (jcscoobyrs) 12-NOV-2003 14:26:00
d = calendar.getTime(); //Revision to fix deprecated methods (jcscoobyrs) 12-NOV-2003 14:26:00
      return d;
  }
 
开发者ID:ser316asu,项目名称:SER316-Munich,代码行数:21,代码来源:EventImpl.java

示例15: testLuceneDateRangeFunctionToDate

import java.util.GregorianCalendar; //导入依赖的package包/类
/**
 * Test generation of lucene date ranges
 *
 */
public void testLuceneDateRangeFunctionToDate()
{
    GregorianCalendar cal = new GregorianCalendar();
    cal.set(Calendar.YEAR, 2001);
    cal.set(Calendar.MONTH, 1);
    cal.set(Calendar.DAY_OF_MONTH, 1);
    String isoStartDate = ISO8601DateFormat.format(cal.getTime());
    cal.add(Calendar.DAY_OF_MONTH, 4);
    String isoEndDate = ISO8601DateFormat.format(cal.getTime());
    String template = "${luceneDateRange(\""+isoStartDate+"\", \""+isoEndDate+"\")}";
    FreeMarkerWithLuceneExtensionsModelFactory mf = new FreeMarkerWithLuceneExtensionsModelFactory();
    mf.setServiceRegistry(serviceRegistry);
    String result = serviceRegistry.getTemplateService().processTemplateString("freemarker", template, mf.getModel());
    assertEquals(result, "["+isoStartDate+" TO "+isoEndDate+"]");
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:20,代码来源:FreeMarkerModelLuceneFunctionTest.java


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