本文整理匯總了Java中java.util.GregorianCalendar.setTimeInMillis方法的典型用法代碼示例。如果您正苦於以下問題:Java GregorianCalendar.setTimeInMillis方法的具體用法?Java GregorianCalendar.setTimeInMillis怎麽用?Java GregorianCalendar.setTimeInMillis使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.GregorianCalendar
的用法示例。
在下文中一共展示了GregorianCalendar.setTimeInMillis方法的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;
}
示例2: getTimeUntilNextAlarmCondition
import java.util.GregorianCalendar; //導入方法依賴的package包/類
private Uri getTimeUntilNextAlarmCondition() {
try {
GregorianCalendar weekRange = new GregorianCalendar();
final long now = weekRange.getTimeInMillis();
setToMidnight(weekRange);
weekRange.roll(Calendar.DATE, 6);
final long nextAlarmMs = (long) XposedHelpers.callMethod(mZenCtrl, "getNextAlarm");
if (nextAlarmMs > 0) {
GregorianCalendar nextAlarm = new GregorianCalendar();
nextAlarm.setTimeInMillis(nextAlarmMs);
setToMidnight(nextAlarm);
if (weekRange.compareTo(nextAlarm) >= 0) {
Object condition = XposedHelpers.callStaticMethod(getZenModeConfigClass(), "toNextAlarmCondition",
mContext, now, nextAlarmMs, SysUiManagers.KeyguardMonitor.getCurrentUserId());
return (Uri) XposedHelpers.getObjectField(condition, "id");
}
}
return null;
} catch (Throwable t) {
XposedBridge.log(t);
return null;
}
}
示例3: convertProductFeature
import java.util.GregorianCalendar; //導入方法依賴的package包/類
private String convertProductFeature(ProductFeature pf)
{
StringBuffer result = new StringBuffer();
//First the uriref for the subject
result.append(startTagWA(3, "ProductFeature", "id", new Integer(pf.getNr()).toString()));
//rdfs:label
result.append(leafTag(4, "label", pf.getLabel()));
//rdfs:comment
result.append(leafTag(4, "comment", pf.getComment()));
//dc:publisher
result.append(leafTag(4, "publisher", pf.getPublisher().toString()));
//dc:date
GregorianCalendar date = new GregorianCalendar();
date.setTimeInMillis(pf.getPublishDate());
String dateString = DateGenerator.formatDate(date);
result.append(leafTag(4, "publishDate", dateString));
result.append(endTag(3, "ProductFeature"));
return result.toString();
}
示例4: toGMTString
import java.util.GregorianCalendar; //導入方法依賴的package包/類
private static String toGMTString(Date date) {
SimpleDateFormat sdf = new SimpleDateFormat(
"EEE, dd MMM y HH:mm:ss 'GMT'", Locale.US);
TimeZone gmtZone = TimeZone.getTimeZone("GMT");
sdf.setTimeZone(gmtZone);
GregorianCalendar gc = new GregorianCalendar(gmtZone);
gc.setTimeInMillis(date.getTime());
return sdf.format(date);
}
示例5: convertPerson
import java.util.GregorianCalendar; //導入方法依賴的package包/類
private void convertPerson(Person person)throws IOException
{
StringBuffer values = getBuffer(tables.personInsertCounter++, "Person");
values.append("(");
//nr
values.append(person.getNr());
values.append(",");
//name
values.append("'");
values.append(person.getName());
values.append("',");
//mbox_sha1sum
values.append("'");
values.append(person.getMbox_sha1sum());
values.append("',");
//country
values.append("'");
values.append(person.getCountryCode());
values.append("',");
//dc:publisher
values.append(person.getPublisher());
values.append(",");
//dc:date
GregorianCalendar date = new GregorianCalendar();
date.setTimeInMillis(person.getPublishDate());
String dateString = DateGenerator.formatDate(date);
values.append("cast ('" + dateString + "' as date))");
if(tables.personInsertCounter>=insertNumber) {
tables.personInsertCounter = 0;
values.append(";\n");
}
tables.personDump.append(values);
}
示例6: julianToDate
import java.util.GregorianCalendar; //導入方法依賴的package包/類
public static Date julianToDate(long date) {
GregorianCalendar calendarBegin = new GregorianCalendar(1, GregorianCalendar.JANUARY, 1);
long millisecondsBegin = calendarBegin.getTimeInMillis();
long diff = date * (24 * 60 * 60 * 1000);
long millisecondsDate = diff + millisecondsBegin;
int days = (int) (millisecondsDate / (24 * 60 * 60 * 1000));
GregorianCalendar calendarDate = new GregorianCalendar();
calendarDate.setTimeInMillis(0);
calendarDate.add(GregorianCalendar.DAY_OF_MONTH, days + 1);//todo : why +1 ?
return calendarDate.getTime();
}
示例7: toNearestInstant
import java.util.GregorianCalendar; //導入方法依賴的package包/類
private long toNearestInstant ( final long timestamp, final TimeUnit reset )
{
final GregorianCalendar cal = new GregorianCalendar ();
cal.setTimeInMillis ( timestamp );
switch ( reset )
{
case DAYS:
cal.add ( Calendar.DAY_OF_YEAR, 1 );
cal.set ( Calendar.HOUR, 0 );
cal.set ( Calendar.MINUTE, 0 );
cal.set ( Calendar.SECOND, 0 );
cal.set ( Calendar.MILLISECOND, 0 );
break;
case HOURS:
cal.add ( Calendar.HOUR, 1 );
cal.set ( Calendar.MINUTE, 0 );
cal.set ( Calendar.SECOND, 0 );
cal.set ( Calendar.MILLISECOND, 0 );
break;
case MINUTES:
cal.add ( Calendar.MINUTE, 1 );
cal.set ( Calendar.SECOND, 0 );
cal.set ( Calendar.MILLISECOND, 0 );
break;
case SECONDS:
cal.add ( Calendar.SECOND, 1 );
cal.set ( Calendar.MILLISECOND, 0 );
break;
default:
break;
}
// in worst case this is the same time as the given one
return cal.getTimeInMillis () - timestamp;
}
示例8: convertProductFeature
import java.util.GregorianCalendar; //導入方法依賴的package包/類
private void convertProductFeature(ProductFeature pf) throws IOException
{
StringBuffer values = getBuffer(tables.productFeatureInsertCounter++, "ProductFeature");
values.append("(");
//nr
values.append(pf.getNr());
values.append(",");
//rdfs:label
values.append("'");
values.append(pf.getLabel());
values.append("',");
//rdfs:comment
values.append("'");
values.append(pf.getComment());
values.append("',");
//dc:publisher
values.append(pf.getPublisher());
values.append(",");
//dc:date
GregorianCalendar date = new GregorianCalendar();
date.setTimeInMillis(pf.getPublishDate());
String dateString = DateGenerator.formatDate(date);
values.append("cast ('");
values.append(dateString);
values.append("' as date))");
if(tables.productFeatureInsertCounter>=insertNumber) {
tables.productFeatureInsertCounter = 0;
values.append(";\n");
}
tables.productFeatureDump.append(values);
}
示例9: formatDateTime
import java.util.GregorianCalendar; //導入方法依賴的package包/類
public static String formatDateTime(Long date) {
GregorianCalendar c = new GregorianCalendar();
c.setTimeInMillis(date);
String dateString = formatDate(c);
return dateString + "T00:00:00";
}
示例10: convertVendor
import java.util.GregorianCalendar; //導入方法依賴的package包/類
private String convertVendor(Vendor vendor)
{
StringBuffer result = new StringBuffer();
//First the uriref for the subject
result.append(startTagWA(3, "Vendor", "id", new Integer(vendor.getNr()).toString()));
//rdfs:label
result.append(leafTag(4, "label", vendor.getLabel()));
//rdfs:comment
result.append(leafTag(4, "comment", vendor.getComment()));
//foaf:homepage
result.append(leafTag(4, "homepage", vendor.getHomepage()));
//bsbm:country
result.append(leafTag(4, "country", vendor.getCountryCode()));
//dc:publisher
result.append(leafTag(4, "publisher", new Integer(vendor.getNr()).toString()));
//dc:date
GregorianCalendar date = new GregorianCalendar();
date.setTimeInMillis(vendor.getPublishDate());
String dateString = DateGenerator.formatDate(date);
result.append(leafTag(4, "publishDate", dateString));
result.append(endTag(3, "Vendor"));
return result.toString();
}
示例11: convertPerson
import java.util.GregorianCalendar; //導入方法依賴的package包/類
private String convertPerson(Person person)
{
StringBuffer result = new StringBuffer();
//First the uriref for the subject
result.append(startTagWA(3, "Person", "id", new Integer(person.getNr()).toString()));
//foaf:name
result.append(leafTag(4, "name", person.getName()));
//foaf:mbox_sha1sum
result.append(leafTag(4, "mbox_sha1sum", person.getMbox_sha1sum()));
//bsbm:country
result.append(leafTag(4, "country", person.getCountryCode()));
//dc:publisher
result.append(leafTag(4, "publisher", person.getPublisher().toString()));
//dc:date
GregorianCalendar date = new GregorianCalendar();
date.setTimeInMillis(person.getPublishDate());
String dateString = DateGenerator.formatDate(date);
result.append(leafTag(4, "publishDate", dateString));
result.append(endTag(3, "Person"));
return result.toString();
}
示例12: getAllRoutes
import java.util.GregorianCalendar; //導入方法依賴的package包/類
public ArrayList<Route> getAllRoutes() {
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery("SELECT * FROM Route", null);
cursor.moveToFirst();
ArrayList<Route> allRoutes = new ArrayList<Route>();
if (cursor.getCount() > 0) {
do {
Route r = new Route();
long id = cursor.getLong(cursor.getColumnIndex(COLUMN_ID));
GregorianCalendar date = new GregorianCalendar();
date.setTimeInMillis(cursor.getLong(cursor.getColumnIndex(COLUMN_DATE)));
r.setDate(date);
r.setScore(cursor.getDouble(cursor.getColumnIndex(COLUMN_SCORE)));
Cursor cursor2 = db.rawQuery("SELECT * FROM " + TABLE_LOC_TIME_CON + " WHERE " + TABLE_LOC_TIME_CON + ".ID In (SELECT " + COLUMN_ID_POINT + " FROM " + TABLE_ROUTE_POINTS + " WHERE ID_Route = " + id + ");", null);
cursor2.moveToFirst();
if (cursor2.getCount() > 0) {
do {
GregorianCalendar gC = new GregorianCalendar();
gC.setTimeInMillis(cursor2.getLong(cursor2.getColumnIndex(COLUMN_TIME)));
LocationTimeConnection ltc = new LocationTimeConnection();
ltc.setDatetime(gC);
ltc.setVelocity(cursor2.getDouble(cursor2.getColumnIndex(COLUMN_VELOCITY)));
ltc.setVolume(cursor2.getDouble(cursor2.getColumnIndex(COLUMN_VOLUME)));
r.add(ltc);
} while (cursor2.moveToNext());
}
allRoutes.add(r);
} while (cursor.moveToNext());
}
this.close();
return allRoutes;
}
示例13: convertReview
import java.util.GregorianCalendar; //導入方法依賴的package包/類
private String convertReview(Review review)
{
StringBuffer result = new StringBuffer();
//First the uriref for the subject
result.append(startTagWA(3, "Review", "id", new Integer(review.getNr()).toString()));
//bsbm:reviewFor
result.append(leafTag(4, "reviewfor", review.getProduct().toString()));
//rev:reviewer
result.append(leafTag(4, "reviewer", new Integer(review.getPerson()).toString()));
//bsbm:reviewDate
GregorianCalendar reviewDate = new GregorianCalendar();
reviewDate.setTimeInMillis(review.getReviewDate());
String reviewDateString = DateGenerator.formatDate(reviewDate);
result.append(leafTag(4, "reviewDate", reviewDateString));
//dc:title
result.append(leafTag(4, "title", review.getTitle()));
//rev:text
result.append(leafTagWA(4, "text", review.getText(), "lang", ISO3166.language[review.getLanguage()]));
//bsbm:ratingX
Integer[] ratings = review.getRatings();
for(Integer i=0,j=1;i<ratings.length;i++,j++)
{
Integer value = ratings[i];
if(value!=null)
result.append(leafTagWA(4, "rating", value.toString(), "nr", j.toString()));
}
//dc:publisher
result.append(leafTag(4, "publisher", review.getPublisher().toString()));
//dc:date
GregorianCalendar date = new GregorianCalendar();
date.setTimeInMillis(review.getPublishDate());
String dateString = DateGenerator.formatDate(date);
result.append(leafTag(4, "publishDate", dateString));
result.append(endTag(3, "Review"));
return result.toString();
}
示例14: convertReview
import java.util.GregorianCalendar; //導入方法依賴的package包/類
private String convertReview(Review review, ObjectBundle bundle)
{
StringBuffer result = new StringBuffer();
//First the uriref for the subject
result.append(Review.getPrefixed(review.getNr(), bundle.getPublisherNum()));
result.append("\n");
//rdf:type
result.append(createTriplePO(
RDF.prefixed("type"),
BSBM.prefixed("Review")));
//bsbm:reviewFor
result.append(createTriplePO(
BSBM.prefixed("reviewFor"),
Product.getPrefixed(review.getProduct(), review.getProducerOfProduct())));
//rev:reviewer
result.append(createTriplePO(
REV.prefixed("reviewer"),
Person.getPrefixed(review.getPerson(), review.getPublisher())));
//dc:title
result.append(createTriplePO(
DC.prefixed("title"),
createLiteral(review.getTitle())));
//rev:text
result.append(createTriplePO(
REV.prefixed("text"),
createLanguageLiteral(review.getText(),ISO3166.language[review.getLanguage()])));
//bsbm:ratingX
Integer[] ratings = review.getRatings();
for(int i=0,j=1;i<ratings.length;i++,j++)
{
Integer value = ratings[i];
if(value!=null)
result.append(createTriplePO(
BSBM.getRatingPrefix(j),
createDataTypeLiteral(value.toString(), XSD.prefixed("integer"))));
}
//bsbm:reviewDate
GregorianCalendar reviewDate = new GregorianCalendar();
reviewDate.setTimeInMillis(review.getReviewDate());
String reviewDateString = DateGenerator.formatDateTime(reviewDate);
result.append(createTriplePO(
BSBM.prefixed("reviewDate"),
createDataTypeLiteral(reviewDateString, XSD.prefixed("dateTime"))));
//dc:publisher
result.append(createTriplePO(
DC.prefixed("publisher"),
RatingSite.getPrefixed(review.getPublisher())));
//dc:date
GregorianCalendar date = new GregorianCalendar();
date.setTimeInMillis(review.getPublishDate());
String dateString = DateGenerator.formatDate(date);
result.append(createTriplePOEnd(
DC.prefixed("date"),
createDataTypeLiteral(dateString, XSD.prefixed("date"))));
return result.toString();
}
示例15: getXMLGregorianCalendar
import java.util.GregorianCalendar; //導入方法依賴的package包/類
private XMLGregorianCalendar getXMLGregorianCalendar(long time) {
GregorianCalendar gc = new GregorianCalendar();
gc.setTimeInMillis(time);
return datatypeFactory.newXMLGregorianCalendar(gc);
}