List of usage examples for org.joda.time.format DateTimeFormat forPattern
public static DateTimeFormatter forPattern(String pattern)
From source file:ca.phon.phon2csv.SpeakerInfoColumn.java
License:Open Source License
@Override public String getData(Session t, Record utt) { Participant speaker = utt.getSpeaker(); if (speaker != null) { String retVal = ""; if (field.equalsIgnoreCase("name")) { retVal = speaker.toString(); } else if (field.equalsIgnoreCase("age")) { if (t.getDate() != null && speaker.getBirthDate() != null) { final AgeFormatter ageFormatter = new AgeFormatter(); retVal = ageFormatter.format(speaker.getAge(t.getDate())); }//w w w.j a v a2 s . c o m } else if (field.equalsIgnoreCase("education")) { retVal = speaker.getEducation(); } else if (field.equalsIgnoreCase("language")) { retVal = speaker.getLanguage(); } else if (field.equalsIgnoreCase("group")) { retVal = speaker.getGroup(); } else if (field.equalsIgnoreCase("sex")) { if (speaker.getSex() != null) { retVal = speaker.getSex().toString(); } } else if (field.equalsIgnoreCase("role")) { retVal = speaker.getRole().getTitle(); } else if (field.equalsIgnoreCase("birthday")) { if (speaker.getBirthDate() != null) { final DateTimeFormatter dateFormatter = DateTimeFormat.forPattern("yyyy-MM-dd"); retVal = dateFormatter.print(speaker.getBirthDate()); } } else { retVal = ""; } return retVal; } else { return ""; } }
From source file:ca.travelagency.utils.DateUtils.java
License:Apache License
public static String formatDateCustom(Date date) { if (date == null) { return StringUtils.EMPTY; }//w ww .j ava2 s . c o m return DateTimeFormat.forPattern(DATE_CUSTOM).print(date.getTime()); }
From source file:ca.travelagency.utils.DateUtils.java
License:Apache License
public static Date parseDateCustom(String date) { if (StringUtils.isBlank(date)) { return null; }/*from www.ja v a2s.com*/ return DateTimeFormat.forPattern(DATE_CUSTOM).parseLocalDate(date).toDate(); }
From source file:ca.travelagency.utils.DateUtils.java
License:Apache License
public static String formatDateAsMonth(Date date) { if (date == null) { return StringUtils.EMPTY; }//from w ww . j a v a 2 s .co m return DateTimeFormat.forPattern(YEAR_MONTH_PATTERN).print(date.getTime()); }
From source file:ca.ualberta.physics.cssdp.jaxb.LocalDateAdapter.java
License:Apache License
public LocalDate unmarshal(String v) throws Exception { return LocalDate.parse(v, DateTimeFormat.forPattern("yyyy-MM-dd")); }
From source file:ca.ualberta.physics.cssdp.jaxb.LocalTimeAdapter.java
License:Apache License
public LocalTime unmarshal(String v) throws Exception { return LocalTime.parse(v, DateTimeFormat.forPattern("HH:mm")); }
From source file:ch.corten.aha.widget.DigitalClock.java
License:Apache License
private void setFormat() { mDateFormat = DateTimeFormat.forPattern(is24HourMode() ? M24 : M12).withZone(mTimeZone); }
From source file:ch.corten.aha.worldclock.TimeZoneInfo.java
License:Open Source License
public static String formatDate(DateFormat dateFormat, DateTimeZone tz, long time) { if (dateFormat instanceof SimpleDateFormat) { String pattern = ((SimpleDateFormat) dateFormat).toPattern(); DateTimeFormatter format = DateTimeFormat.forPattern(pattern).withZone(tz); return format.print(time); } else {//from w w w. j a va 2 s .c om dateFormat.setTimeZone(convertToJavaTimeZone(tz, time)); return dateFormat.format(new Date(time)); } }
From source file:ch.corten.aha.worldclock.TimeZoneInfo.java
License:Open Source License
public static String showDifferentWeekday(DateTimeZone tz, long time) { DateTimeFormatter dayFormat = DateTimeFormat.forPattern(WEEKDAY_FORMAT).withZone(tz); String day = dayFormat.print(time); DateTimeFormatter localDayFormat = DateTimeFormat.forPattern(WEEKDAY_FORMAT); if (!day.equals(localDayFormat.print(time))) { return " " + day; }//from w w w . j ava 2s. com return ""; }
From source file:ch.eitchnet.android.mabea.MabeaParsing.java
License:Open Source License
public static LocalDateTime parseStateTime(String value) throws MabeaParsingException { try {//from www .ja va 2 s . co m int posOpenBracket = value.indexOf('('); int posCloseBracket = value.indexOf(')'); String time = value.substring(posOpenBracket + 1, posCloseBracket); LocalTime localTime = DateTimeFormat.forPattern("HH:mm").parseLocalTime(time); return LocalDate.now().toLocalDateTime(localTime); } catch (Exception e) { throw new MabeaParsingException("State time can not be parsed from value " + value, e); } }