本文整理匯總了Java中org.joda.time.Instant.parse方法的典型用法代碼示例。如果您正苦於以下問題:Java Instant.parse方法的具體用法?Java Instant.parse怎麽用?Java Instant.parse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.joda.time.Instant
的用法示例。
在下文中一共展示了Instant.parse方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: apply
import org.joda.time.Instant; //導入方法依賴的package包/類
/**
* input - a tupel that contains the data element (TableRow), the window, the timestamp, and the pane
*/
@Override
public TableDestination apply(ValueInSingleWindow<TableRow> input) {
String partition;
if (this.isTimeField) {
String sTime = (String) input.getValue().get(this.fieldName);
Instant time = Instant.parse(sTime);
partition = time.toString(partitionFormatter);
} else {
partition = ((Integer) input.getValue().get(this.fieldName)).toString();
}
TableReference reference = new TableReference();
reference.setProjectId(this.projectId);
reference.setDatasetId(this.datasetId);
reference.setTableId(this.partitionPrefix + partition);
return new TableDestination(reference, null);
}
示例2: testNotesWithTimesSkipDoneState
import org.joda.time.Instant; //導入方法依賴的package包/類
@Test
public void testNotesWithTimesSkipDoneState() {
shelfTestUtils.setupBook("notebook",
"* Note 1\n"+
"SCHEDULED: <2017-03-20>\n" +
"* DONE Note 2\n"+
"SCHEDULED: <2017-03-20>\n" +
"* Note 3");
ReminderService.LastRun lastRun = new ReminderService.LastRun();
Instant now = Instant.parse("2017-03-15");
AppPreferences.remindersForScheduledEnabled(context, true);
List<NoteReminder> notes = ReminderService.getNoteReminders(
context, now, lastRun, ReminderService.TIME_FROM_NOW);
assertEquals(1, notes.size());
}
示例3: testNotesWithTimesWithRepeater
import org.joda.time.Instant; //導入方法依賴的package包/類
@Test
public void testNotesWithTimesWithRepeater() {
shelfTestUtils.setupBook("notebook",
"* Note 1\n"+
"SCHEDULED: <2017-03-10 Fri +1w>\n" +
"* Note 2\n"+
"SCHEDULED: <2017-03-20 Mon 16:00>\n" +
"* Note 3\n" +
"* Note 4\n"+
"SCHEDULED: <2017-03-16 Fri +1w>\n");
ReminderService.LastRun lastRun = new ReminderService.LastRun();
Instant now = Instant.parse("2017-03-15T13:00:00"); // Wed
AppPreferences.remindersForScheduledEnabled(context, true);
List<NoteReminder> notes = ReminderService.getNoteReminders(
context, now, lastRun, ReminderService.TIME_FROM_NOW);
assertEquals(2, notes.size());
assertEquals("Note 4", notes.get(0).getPayload().title);
assertEquals("2017-03-16T09:00:00", new LocalDateTime(notes.get(0).getRunTime()).toString("yyyy-MM-dd'T'HH:mm:ss"));
assertEquals("Note 2", notes.get(1).getPayload().title);
assertEquals("2017-03-20T16:00:00", new LocalDateTime(notes.get(1).getRunTime()).toString("yyyy-MM-dd'T'HH:mm:ss"));
}
示例4: testReminderForDeadlineTime
import org.joda.time.Instant; //導入方法依賴的package包/類
@Test
public void testReminderForDeadlineTime() {
shelfTestUtils.setupBook("notebook",
"* Note 1\n"+
"SCHEDULED: <2017-03-16 Fri +1w>\n" +
"* Note 2\n"+
"DEADLINE: <2017-03-20 Mon 16:00>\n");
ReminderService.LastRun lastRun = new ReminderService.LastRun();
Instant now = Instant.parse("2017-03-15T13:00:00"); // Wed
AppPreferences.remindersForDeadlineEnabled(context, true);
List<NoteReminder> notes = ReminderService.getNoteReminders(
context, now, lastRun, ReminderService.TIME_FROM_NOW);
assertEquals(1, notes.size());
NoteReminder reminder = notes.get(0);
assertEquals("Note 2", reminder.getPayload().title);
assertEquals(DbTimeView.DEADLINE_TIME, reminder.getPayload().timeType);
assertEquals("2017-03-20T16:00:00", new LocalDateTime(reminder.getRunTime()).toString("yyyy-MM-dd'T'HH:mm:ss"));
}
示例5: testLengthsOfEncodingChoices
import org.joda.time.Instant; //導入方法依賴的package包/類
/**
* This is a change detector test for the sizes of encoded windows. Since these are present
* for every element of every windowed PCollection, the size matters.
*
* <p>This test documents the expectation that encoding as a (endpoint, duration) pair
* using big endian for the endpoint and variable length long for the duration should be about 25%
* smaller than encoding two big endian Long values.
*/
@Test
public void testLengthsOfEncodingChoices() throws Exception {
Instant start = Instant.parse("2015-04-01T00:00:00Z");
Instant minuteEnd = Instant.parse("2015-04-01T00:01:00Z");
Instant hourEnd = Instant.parse("2015-04-01T01:00:00Z");
Instant dayEnd = Instant.parse("2015-04-02T00:00:00Z");
Coder<Instant> instantCoder = InstantCoder.of();
byte[] encodedStart = CoderUtils.encodeToByteArray(instantCoder, start);
byte[] encodedMinuteEnd = CoderUtils.encodeToByteArray(instantCoder, minuteEnd);
byte[] encodedHourEnd = CoderUtils.encodeToByteArray(instantCoder, hourEnd);
byte[] encodedDayEnd = CoderUtils.encodeToByteArray(instantCoder, dayEnd);
byte[] encodedMinuteWindow = CoderUtils.encodeToByteArray(
TEST_CODER, new IntervalWindow(start, minuteEnd));
byte[] encodedHourWindow = CoderUtils.encodeToByteArray(
TEST_CODER, new IntervalWindow(start, hourEnd));
byte[] encodedDayWindow = CoderUtils.encodeToByteArray(
TEST_CODER, new IntervalWindow(start, dayEnd));
assertThat(encodedMinuteWindow.length,
equalTo(encodedStart.length + encodedMinuteEnd.length - 5));
assertThat(encodedHourWindow.length,
equalTo(encodedStart.length + encodedHourEnd.length - 4));
assertThat(encodedDayWindow.length,
equalTo(encodedStart.length + encodedDayEnd.length - 4));
}
示例6: getTestData
import org.joda.time.Instant; //導入方法依賴的package包/類
/**
* Generate 5 timeseries values across a 10 min window TS1, TS2, TS3, TS4, TS5. TS1 / TS2 Will
* contain a single value per 1 min and will increase by a value of 1 till min 5 and then decrease
* by a value of 1 until 10 mins TS3 Will have missing values at 2, 3, 7 and 8 mins and will
* decrease by a value of 1 till min 5 and then increase by a value of 1 until 10 mins TS4 Will
* have missing values at 2, 3, 7 and 8 mins and will decrease by a value of 1 till min 5 and then
* increase by a value of 1 until 10 mins TS5 Will have random values assigned to it throughout
* the process this is the control time series
*/
public static List<KV<String, TSProto>> getTestData() {
List<KV<String, TSProto>> ts = new ArrayList<KV<String, TSProto>>();
String dateTime = "01/01/2016 00:00:00";
DateTimeFormatter dtf = DateTimeFormat.forPattern("dd/MM/yyyy HH:mm:ss");
Instant time = Instant.parse(dateTime, dtf);
// KEY 001 & KEY 002
String[] list = {TS1, TS2};
for (String s : list) {
GenerateSampleData.generateSequentialList(ts, time, s, 1d, 1d);
}
// KEY003
List<KV<String, TSProto>> key003List = new ArrayList<KV<String, TSProto>>();
GenerateSampleData.generateSequentialList(key003List, time, TS3, 10d, -1d);
// Remove values
key003List.remove(2); // Remove time value 02
key003List.remove(2); // Remove time value 03
key003List.remove(5); // Remove time value 07
key003List.remove(5); // Remove time value 08
ts.addAll(key003List);
// KEY004
List<KV<String, TSProto>> key004List = new ArrayList<KV<String, TSProto>>();
GenerateSampleData.generateSequentialList(key004List, time, TS4, 10d, -1d);
// Remove values
key004List.remove(2); // Remove time value 02
key004List.remove(2); // Remove time value 03
key004List.remove(5); // Remove time value 07
key004List.remove(5); // Remove time value 08
ts.addAll(key004List);
// KEY005
Instant tsTime = new Instant(time);
for (int i = 0; i < 10; i++) {
ts.add(KV.of(TS5, TSProto.newBuilder().setAskPrice(Math.random()).setBidPrice(Math.random())
.setKey(TS5).setIsLive(true).setTime(tsTime.getMillis()).build()));
tsTime = tsTime.plus(Duration.standardMinutes(1));
}
return ts;
}