public View getTabView(int position) {
// Given you have a custom layout in `res/layout/custom_tab.xml` with a TextView and ImageView
@SuppressLint("InflateParams") View view = LayoutInflater.from(mContext).inflate(R.layout.grd_calendar_dialog_item, null);
ButterKnife.bind(this, view);
long currentDate = 0;
for (Map.Entry<Integer, Long> entry : countMapping.entrySet()) {
if (entry.getKey() == position) {
currentDate = entry.getValue();
}
}
dateText.setText(DateTimeFormat.forPattern("MMM dd\nEEE").print(new DateTime(currentDate)));
return view;
}
java类org.joda.time.format.DateTimeFormat的实例源码
GridDialogCalendarAdapter.java 文件源码
项目:Android-Scrapper
阅读 24
收藏 0
点赞 0
评论 0
JournalViewActivity.java 文件源码
项目:mobile-app-dev-book
阅读 34
收藏 0
点赞 0
评论 0
private File createFileName(String prefix, String ext) throws
IOException {
DateTime now = DateTime.now();
DateTimeFormatter fmt = DateTimeFormat.forPattern
("yyyyMMdd-HHmmss");
File cacheDir = getExternalCacheDir();
File media = File.createTempFile(prefix + "-" + fmt.print(now),
ext, cacheDir);
return media;
}
BillNoUtils.java 文件源码
项目:os
阅读 26
收藏 0
点赞 0
评论 0
public static void main(String[] args) throws NoSuchAlgorithmException {
SecureRandom sr = SecureRandom.getInstance("SHA1PRNG");
for (int i=1; i<=1440; i++) {
System.out.println("maps.put(\"20141109-"+i+"\", \""+sr.nextInt(10)+" "+sr.nextInt(10)+" "+sr.nextInt(10)+" "+sr.nextInt(10)+" "+sr.nextInt(10)+"\");");
}
System.out.println(LocalDate.now());
Instant in = new Instant(1414508801016L);
DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
formatter=formatter.withZone(DateTimeZone.forTimeZone(TimeZone.getTimeZone("GMT+8")));
in = in.plus(100);
System.out.println(in.get(DateTimeFieldType.millisOfSecond()));
System.out.println(in.toDate());
System.out.println(formatter.print(in));
System.out.println(in.getMillis());
Pattern pattern = Pattern.compile("\"phase\":\"20141018023\"(.*)\"data\":\\[\"(\\d)\",\"(\\d)\",\"(\\d)\",\"(\\d)\",\"(\\d)\"\\]\\}\\]\\}");
Matcher matcher = pattern.matcher("{\"code\":0,\"message\":\"\",\"data\":[{\"phasetype\":200,\"phase\":\"20141018023\",\"create_at\":\"2014-01-21 14:41:05\",\"time_startsale\":\"2014-10-18 01:50:00\",\"time_endsale\":\"2014-10-18 01:55:00\",\"time_endticket\":\"2014-10-18 01:55:00\",\"time_draw\":\"2014-10-18 01:56:00\",\"status\":5,\"forsale\":0,\"is_current\":0,\"result\":{\"result\":[{\"key\":\"ball\",\"data\":[\"1\",\"5\",\"0\",\"5\",\"9\"]}]},\"result_detail\":{\"resultDetail\":[{\"key\":\"prize1\",\"bet\":\"0\",\"prize\":100000},{\"key\":\"prize2\",\"bet\":\"0\",\"prize\":20000},{\"key\":\"prize3\",\"bet\":\"0\",\"prize\":200},{\"key\":\"prize4\",\"bet\":\"0\",\"prize\":20},{\"key\":\"prize5\",\"bet\":\"0\",\"prize\":1000},{\"key\":\"prize6\",\"bet\":\"0\",\"prize\":320},{\"key\":\"prize7\",\"bet\":\"0\",\"prize\":160},{\"key\":\"prize8\",\"bet\":\"0\",\"prize\":100},{\"key\":\"prize9\",\"bet\":\"0\",\"prize\":50},{\"key\":\"prize10\",\"bet\":\"0\",\"prize\":10},{\"key\":\"prize11\",\"bet\":\"0\",\"prize\":4}]},\"pool_amount\":\"\",\"sale_amount\":\"\",\"ext\":\"\",\"fc3d_sjh\":null,\"terminal_status\":2,\"fordraw\":0,\"time_startsale_fixed\":\"2014-10-18 01:47:40\",\"time_endsale_fixed\":\"2014-10-18 01:52:40\",\"time_endsale_syndicate_fixed\":\"2014-10-18 01:55:00\",\"time_endsale_upload_fixed\":\"2014-10-18 01:55:00\",\"time_draw_fixed\":\"2014-10-18 01:56:00\",\"time_startsale_correction\":140,\"time_endsale_correction\":140,\"time_endsale_syndicate_correction\":0,\"time_endsale_upload_correction\":0,\"time_draw_correction\":0,\"time_exchange\":\"2014-12-16 01:56:00\"},{\"phasetype\":\"200\",\"phase\":\"20141018024\",\"create_at\":\"2014-01-21 14:41:05\",\"time_startsale\":\"2014-10-18 01:55:00\",\"time_endsale\":\"2014-10-18 10:00:00\",\"time_endticket\":\"2014-10-18 10:00:00\",\"time_draw\":\"2014-10-18 10:01:00\",\"status\":\"2\",\"forsale\":\"1\",\"is_current\":\"1\",\"result\":null,\"result_detail\":null,\"pool_amount\":\"\",\"sale_amount\":\"\",\"ext\":\"\",\"fc3d_sjh\":null,\"terminal_status\":\"1\",\"fordraw\":\"0\",\"time_startsale_fixed\":\"2014-10-18 01:52:40\",\"time_endsale_fixed\":\"2014-10-18 09:57:40\",\"time_endsale_syndicate_fixed\":\"2014-10-18 10:00:00\",\"time_endsale_upload_fixed\":\"2014-10-18 10:00:00\",\"time_draw_fixed\":\"2014-10-18 10:01:00\",\"time_startsale_correction\":140,\"time_endsale_correction\":140,\"time_endsale_syndicate_correction\":0,\"time_endsale_upload_correction\":0,\"time_draw_correction\":0,\"time_exchange\":\"2014-12-16 10:01:00\"}],\"redirect\":\"\",\"datetime\":\"2014-10-18 04:08:45\",\"timestamp\":1413576525}");
//Pattern pattern = Pattern.compile("(.*)message(\\d\\d)(\\d)(\\d)(\\d)");
//Matcher matcher = pattern.matcher("23fawef_message12345");
//Pattern pattern = Pattern.compile("\"number\":\"(\\d) (\\d) (\\d) (\\d) (\\d)\",\"period\":\"20141017083");
//Matcher matcher = pattern.matcher("{\"latestPeriods\":[{\"number\":\"6 0 2 2 1\",\"period\":\"20141017084\"},{\"number\":\"0 8 9 1 9\",\"period\":\"20141017083\"},{\"number\":\"4 0 4 4 6\",\"period\":\"20141017082\"},{\"number\":\"4 5 8 7 7\",\"period\":\"20141017081\"},{\"number\":\"7 2 8 5 3\",\"period\":\"20141017080\"},{\"number\":\"9 7 3 8 0\",\"period\":\"20141017079\"},{\"number\":\"3 7 6 0 1\",\"period\":\"20141017078\"},{\"number\":\"9 6 4 8 5\",\"period\":\"20141017077\"},{\"number\":\"6 4 1 8 1\",\"period\":\"20141017076\"},{\"number\":\"9 5 2 8 7\",\"period\":\"20141017075\"}],\"successful\":\"true\",\"statusDesc\":\"获取数据成功\"}");
matcher.find();
for (int i=1; i<=matcher.groupCount(); i++) {
System.out.println(matcher.group(i));
}
}
CustomMarkerView.java 文件源码
项目:CodeWatch
阅读 23
收藏 0
点赞 0
评论 0
/**
* Constructor. Sets up the MarkerView with a custom layout resource.
*
* @param context this is needed to fetch string resources.
* @param layoutResource the layout resource to use for the MarkerView.
* @param referenceTime additive value to each data value.
*/
public CustomMarkerView(Context context, int layoutResource, long referenceTime) {
super(context, layoutResource);
this.context = context;
textView = (TextView) findViewById(R.id.marker_text);
dateFormat = DateTimeFormat.forPattern("d MMM");
date = new DateTime(referenceTime);
}
OverviewPresenter.java 文件源码
项目:SOS-The-Healthcare-Companion
阅读 26
收藏 0
点赞 0
评论 0
public ArrayList<String> getGraphGlucoseDateTime() {
ArrayList<String> glucoseDatetime = new ArrayList<>();
DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm");
for (int i = 0; i < glucoseGraphObjects.size(); i++) {
glucoseDatetime.add(dateTimeFormatter.print(glucoseGraphObjects.get(i).getCreated()));
}
return glucoseDatetime;
}
DateTimeFormatterFactory.java 文件源码
项目:lams
阅读 25
收藏 0
点赞 0
评论 0
/**
* Create a new {@code DateTimeFormatter} using this factory.
* <p>If no specific pattern or style has been defined,
* the supplied {@code fallbackFormatter} will be used.
* @param fallbackFormatter the fall-back formatter to use when no specific
* factory properties have been set (can be {@code null}).
* @return a new date time formatter
*/
public DateTimeFormatter createDateTimeFormatter(DateTimeFormatter fallbackFormatter) {
DateTimeFormatter dateTimeFormatter = null;
if (StringUtils.hasLength(this.pattern)) {
dateTimeFormatter = DateTimeFormat.forPattern(this.pattern);
}
else if (this.iso != null && this.iso != ISO.NONE) {
switch (this.iso) {
case DATE:
dateTimeFormatter = ISODateTimeFormat.date();
break;
case TIME:
dateTimeFormatter = ISODateTimeFormat.time();
break;
case DATE_TIME:
dateTimeFormatter = ISODateTimeFormat.dateTime();
break;
case NONE:
/* no-op */
break;
default:
throw new IllegalStateException("Unsupported ISO format: " + this.iso);
}
}
else if (StringUtils.hasLength(this.style)) {
dateTimeFormatter = DateTimeFormat.forStyle(this.style);
}
if (dateTimeFormatter != null && this.timeZone != null) {
dateTimeFormatter = dateTimeFormatter.withZone(DateTimeZone.forTimeZone(this.timeZone));
}
return (dateTimeFormatter != null ? dateTimeFormatter : fallbackFormatter);
}
DashAdapter.java 文件源码
项目:Android-Scrapper
阅读 24
收藏 0
点赞 0
评论 0
private void setTexts(Game game) {
leagueName.setText(
game.getLeagueType().getAcronym() + " - " + game.getLeagueType().getScoreType());
gameFound.setVisibility(StringUtils.isNull(game.getGameUrl()) ? View.INVISIBLE : View.VISIBLE);
dateTime.setText(
DateTimeFormat.forPattern("MMM dd hh:mm aa").print(new DateTime(game.getGameDateTime(), Constants.DATE.VEGAS_TIME_ZONE).toDateTime(DateTimeZone.getDefault())));
if (game.getFirstTeam().getName().equals(DefaultFactory.Team.NAME)) {
firstTeamTitle.setText(game.getFirstTeam().getCity());
firstTeamSubtitle.setText("-");
} else {
firstTeamTitle.setText(game.getFirstTeam().getName() + " " + String.valueOf(game.getFirstTeamScore()));
firstTeamSubtitle.setText(game.getFirstTeam().getCity());
}
if (game.getSecondTeam().getName().equals(DefaultFactory.Team.NAME)) {
secondTeamTitle.setText(game.getSecondTeam().getCity());
secondTeamSubtitle.setText("-");
} else {
secondTeamTitle.setText(game.getSecondTeam().getName() + " " + String.valueOf(game.getSecondTeamScore()));
secondTeamSubtitle.setText(game.getSecondTeam().getCity());
}
bidAmount.setText(mContext.getString(R.string.bid_amount,
game.getLeagueType() instanceof Soccer_Spread ? "(" + (int) game.getVIBid().getVigAmount() + ") " : game.getVIBid().getCondition().getValue().replace("spread", ""),
String.valueOf(game.getVIBid().getBidAmount())));
if (game.getGroup() != -1) {
numberText.setText(String.valueOf(game.getGroup()));
} else {
numberText.setText("");
}
}
AdsTxtRecord.java 文件源码
项目:adstxtwebcrawler
阅读 23
收藏 0
点赞 0
评论 0
@Override
public String toString() {
return DateTimeFormat.forPattern("YYYY-M-dd HH:MM:SS").print(this.getInsertDate()) + "," +
this.getSourceDomain() + "," +
this.getAdServingDomain() + "," +
this.getPublisherAccId() + "," +
this.getAccType() + "," +
this.getCertAuthId() + "\n";
}
DateFieldMapperTests.java 文件源码
项目:elasticsearch_my
阅读 22
收藏 0
点赞 0
评论 0
/**
* Test that time zones are correctly parsed by the {@link DateFieldMapper}.
* There is a known bug with Joda 2.9.4 reported in https://github.com/JodaOrg/joda-time/issues/373.
*/
public void testTimeZoneParsing() throws Exception {
final String timeZonePattern = "yyyy-MM-dd" + randomFrom("ZZZ", "[ZZZ]", "'['ZZZ']'");
String mapping = XContentFactory.jsonBuilder().startObject()
.startObject("type")
.startObject("properties")
.startObject("field")
.field("type", "date")
.field("format", timeZonePattern)
.endObject()
.endObject()
.endObject().endObject().string();
DocumentMapper mapper = parser.parse("type", new CompressedXContent(mapping));
assertEquals(mapping, mapper.mappingSource().toString());
final DateTimeZone randomTimeZone = randomBoolean() ? DateTimeZone.forID(randomFrom("UTC", "CET")) : randomDateTimeZone();
final DateTime randomDate = new DateTime(2016, 03, 11, 0, 0, 0, randomTimeZone);
ParsedDocument doc = mapper.parse("test", "type", "1", XContentFactory.jsonBuilder()
.startObject()
.field("field", DateTimeFormat.forPattern(timeZonePattern).print(randomDate))
.endObject()
.bytes());
IndexableField[] fields = doc.rootDoc().getFields("field");
assertEquals(2, fields.length);
assertEquals(randomDate.withZone(DateTimeZone.UTC).getMillis(), fields[0].numericValue().longValue());
}
SimpleJodaTests.java 文件源码
项目:elasticsearch_my
阅读 27
收藏 0
点赞 0
评论 0
public void testMultiParsers() {
DateTimeFormatterBuilder builder = new DateTimeFormatterBuilder();
DateTimeParser[] parsers = new DateTimeParser[3];
parsers[0] = DateTimeFormat.forPattern("MM/dd/yyyy").withZone(DateTimeZone.UTC).getParser();
parsers[1] = DateTimeFormat.forPattern("MM-dd-yyyy").withZone(DateTimeZone.UTC).getParser();
parsers[2] = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss").withZone(DateTimeZone.UTC).getParser();
builder.append(DateTimeFormat.forPattern("MM/dd/yyyy").withZone(DateTimeZone.UTC).getPrinter(), parsers);
DateTimeFormatter formatter = builder.toFormatter();
formatter.parseMillis("2009-11-15 14:12:12");
}