本文整理汇总了Java中org.joda.time.DateTime.getMonthOfYear方法的典型用法代码示例。如果您正苦于以下问题:Java DateTime.getMonthOfYear方法的具体用法?Java DateTime.getMonthOfYear怎么用?Java DateTime.getMonthOfYear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.joda.time.DateTime
的用法示例。
在下文中一共展示了DateTime.getMonthOfYear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateNewUploadId
import org.joda.time.DateTime; //导入方法依赖的package包/类
/**
* Creates a new uploadId from the time:
* format("%d-%02d-%02d %02d:%02d:%02d", year, month, day, hour, minute, seconds);
* @return
*/
public static String generateNewUploadId() {
java.util.Date juDate = new Date();
DateTime dt = new DateTime(juDate);
StringBuilder sb = new StringBuilder();
// Send all output to the Appendable object sb
Formatter formatter = new Formatter(sb);
int day = dt.getDayOfMonth();
int month = dt.getMonthOfYear();
int year = dt.getYear();
int hour = dt.getHourOfDay();
int minute = dt.getMinuteOfHour();
int seconds = dt.getSecondOfMinute();
formatter.format("%d-%02d-%02d %02d:%02d:%02d", year, month, day, hour, minute, seconds);
return sb.toString();
}
开发者ID:UMM-CSci-3601-S17,项目名称:digital-display-garden-iteration-4-revolverenguardia-1,代码行数:26,代码来源:ExcelParser.java
示例2: getAvailableUploadId
import org.joda.time.DateTime; //导入方法依赖的package包/类
public static String getAvailableUploadId(){
StringBuilder sb = new StringBuilder();
// Send all output to the Appendable object sb
Formatter formatter = new Formatter(sb);
java.util.Date juDate = new Date();
DateTime dt = new DateTime(juDate);
int day = dt.getDayOfMonth();
int month = dt.getMonthOfYear();
int year = dt.getYear();
int hour = dt.getHourOfDay();
int minute = dt.getMinuteOfHour();
int seconds = dt.getSecondOfMinute();
formatter.format("%d-%02d-%02d %02d:%02d:%02d", year, month, day, hour, minute, seconds);
return sb.toString();
}
开发者ID:UMM-CSci-3601-S17,项目名称:digital-display-garden-iteration-3-sixguysburgers-fries,代码行数:21,代码来源:ImageHandler.java
示例3: checkAndConvertDate
import org.joda.time.DateTime; //导入方法依赖的package包/类
protected static final DateTime checkAndConvertDate(final String dateString, final boolean hideErrors) {
DateTime dateToReturn = new DateTime();
try {
dateToReturn = new DateTime().parse(dateString);
if(!hideErrors && (dateString.length() != 10 || dateToReturn.getYear() <= 0 ||
dateToReturn.getMonthOfYear() <= 0 || dateToReturn.getDayOfMonth() <= 0)) {
throw new IllegalArgumentException();
}
} catch(IllegalArgumentException e) {
if(!hideErrors) { e.printStackTrace(); }
dateToReturn = null;
}
return dateToReturn;
}
示例4: getAvailableUploadId
import org.joda.time.DateTime; //导入方法依赖的package包/类
public static String getAvailableUploadId(){
StringBuilder sb = new StringBuilder();
// Send all output to the Appendable object sb
Formatter formatter = new Formatter(sb);
java.util.Date juDate = new Date();
DateTime dt = new DateTime(juDate);
int day = dt.getDayOfMonth();
int month = dt.getMonthOfYear();
int year = dt.getYear();
int hour = dt.getHourOfDay();
int minute = dt.getMinuteOfHour();
int seconds = dt.getSecondOfMinute();
formatter.format("%d-%02d-%02d %02d:%02d:%02d", year, month, day, hour, minute, seconds);
allIds.add(sb.toString());
return sb.toString();
}
开发者ID:UMM-CSci-3601-S17,项目名称:digital-display-garden-iteration-3-sixguysburgers-fries,代码行数:22,代码来源:ExcelParser.java
示例5: Calendar
import org.joda.time.DateTime; //导入方法依赖的package包/类
public Calendar(DateTime firstMonth, DateTime lastMonth) {
this.firstMonth = firstMonth;
this.firstDayOfWeek = java.util.Calendar.getInstance(Locale.getDefault()).getFirstDayOfWeek();
DateTime startMonth = firstMonth.plusMonths(1);
int monthsBetweenCount = Months.monthsBetween(firstMonth, lastMonth).getMonths();
months = new ArrayList<>();
months.add(firstMonth);
currentMonth = firstMonth;
DateTime monthToAdd = new DateTime(startMonth.getYear(), startMonth.getMonthOfYear(), 1, 0, 0);
for (int i = 0; i <= monthsBetweenCount; i++) {
months.add(monthToAdd);
monthToAdd = monthToAdd.plusMonths(1);
}
}
示例6: testCurrentTime
import org.joda.time.DateTime; //导入方法依赖的package包/类
/**
* 获取当前时间
* 本月几号
* 获取月份
* 获取年份
*/
@Test
public void testCurrentTime() {
// 获取当前时间
DateTime dt = new DateTime();
String currentTime = dt.toString("yyyy-MM-dd HH:mm:ss");
System.out.println("currentTime: " + currentTime);
// 获取当前月的几号
int day = dt.getDayOfMonth();
System.out.println("day: " + day);
// 获取当年的月份
int month = dt.getMonthOfYear();
System.out.println("month: " + month);
// 获取年份
int year = dt.getYear();
System.out.println("year: " + year);
}
示例7: addMonthView
import org.joda.time.DateTime; //导入方法依赖的package包/类
private void addMonthView() {
View calendar = LayoutInflater.from(getContext()).inflate(R.layout.layout_calendar_content, this, false);
calendar.setLayoutParams(new LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, calendarHeight));
viewPagerContent = (ViewPager) calendar.findViewById(R.id.viewpager_calendar);
addView(calendar);
DateTime startDay = new DateTime();
calendarPagerAdapter = new CalendarPagerAdapter(getContext(), calendarHeight, startDay.getYear(), startDay.getMonthOfYear(), getViewHelper);
viewPagerContent.setAdapter(calendarPagerAdapter);
viewPagerContent.setCurrentItem(CENTER_POSITION);
}
示例8: getCurrentMonth
import org.joda.time.DateTime; //导入方法依赖的package包/类
/**
* 获取当前显示月份
* @return current month
*/
public int getCurrentMonth(){
int intervalMonth = viewPagerContent.getCurrentItem() - CENTER_POSITION;
DateTime dateTime = new DateTime(calendarPagerAdapter.getStartYear(), calendarPagerAdapter.getStartMonth(), 1, 0, 0)
.plusMonths(intervalMonth);
return dateTime.getMonthOfYear();
}
示例9: getDateIdFromTimestamp
import org.joda.time.DateTime; //导入方法依赖的package包/类
public static int getDateIdFromTimestamp(long millis) {
int result;
DateTime dt = new DateTime(millis, DateTimeZone.UTC);
int year = dt.getYear();
int month = dt.getMonthOfYear();
int day = dt.getDayOfMonth();
result = day + (100 * month) + (10000 * year);
return result;
}
示例10: getStartSinceDay
import org.joda.time.DateTime; //导入方法依赖的package包/类
private static final DateTime getStartSinceDay(int days) {
DateTime utcNow = new DateTime(DateTimeZone.UTC);
DateTime
today =
new DateTime(utcNow.getYear(), utcNow.getMonthOfYear(), utcNow.getDayOfMonth(), 0, 0, 0,
DateTimeZone.UTC);
return today.minusDays(days);
}
示例11: computeStandardTotalPrice
import org.joda.time.DateTime; //导入方法依赖的package包/类
@JsonIgnore
public void computeStandardTotalPrice() {
DateTime dtBegin = new DateTime(begin);
DateTime dtEnd = new DateTime(end);
DateTime dayBegin = new DateTime(dtBegin.getYear(), dtBegin.getMonthOfYear(), dtBegin.getDayOfMonth(), 0, 0, 0);
DateTime dayEnd = new DateTime(dtEnd.getYear(), dtEnd.getMonthOfYear(), dtEnd.getDayOfMonth(), 0, 0, 0);
Duration duration = new Duration(dayBegin, dayEnd);
double price = getAccommodation().getPricePerDay() * duration.getStandardDays();
totalPrice = Math.round(price * 100) / 100;
}
示例12: parseTime
import org.joda.time.DateTime; //导入方法依赖的package包/类
/**
* 解析API传回的时间 XXXX-XX-XX 的字符串, 转换为中文指代的时间, 比如 "今天 02/09"
*/
public static String parseTime(String timeText){
DateTime dateTime = new DateTime();
String[] time = timeText.split("-");
int currentMonth = dateTime.getMonthOfYear();
int currentDay = dateTime.getDayOfMonth();
int currentWeak = dateTime.getDayOfWeek();
int currentYear = dateTime.getYear();
int month = Integer.parseInt(time[1]);
int day = Integer.parseInt(time[2]);
int year = Integer.parseInt(time[0]);
int offset = 0; // 相差量
if (year == currentYear){
//如果是同一年:
if (month == currentMonth){
// 如果是同一个月
offset = day - currentDay;
}else{
offset = day + parseMonth(currentMonth, currentYear) - currentDay;
}
}else{
offset = 31 - currentDay + day;
}
String monthAndDay = time[1] + "/" + time[2];
if (offset == 0) return "今天 " + monthAndDay;
if (offset == 1) return "明天 " + monthAndDay;
return parseWeak(currentWeak + offset) + " " + monthAndDay;
}
示例13: formatDate
import org.joda.time.DateTime; //导入方法依赖的package包/类
private String formatDate (DateTime beg, DateTime end) {
if (beg.getYear() != end.getYear())
return longFormat.print(beg) + "-" + longFormat.print(end);
if (beg.getMonthOfYear() != end.getMonthOfYear())
return medFormat.print(beg) + "-" + medFormat.print(end) + ", " + beg
.getYear();
return shortFormat.print(beg) + " " + beg.getDayOfMonth() + "-" +
end.getDayOfMonth() + ", " + beg.getYear();
}
示例14: onCreateDialog
import org.joda.time.DateTime; //导入方法依赖的package包/类
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
DateTime selectedDate = model.getSelectedDateTime();
return new DatePickerDialog(getActivity(), listener, selectedDate.getYear(), selectedDate.getMonthOfYear(), selectedDate.getDayOfMonth());
}
示例15: parseDate
import org.joda.time.DateTime; //导入方法依赖的package包/类
public static long parseDate(String dateTime) {
DateTimeFormatter formatter = DateTimeFormat.forPattern("MM/dd hh:mm aa");
DateTime d = formatter.parseDateTime(dateTime);
DateTime dt = new DateTime(Calendar.getInstance().get(Calendar.YEAR), d.getMonthOfYear(), d.getDayOfMonth(), d.getHourOfDay(), d.getMinuteOfHour(), Constants.DATE.VEGAS_TIME_ZONE);
return dt.getMillis();
}