当前位置: 首页>>代码示例>>Java>>正文


Java DateTime.getMonthOfYear方法代码示例

本文整理汇总了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;
}
 
开发者ID:ricomaster9000,项目名称:sageOneApiLibrary-GLOBAL,代码行数:17,代码来源:SageOneApiTemplateMainImpl.java

示例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);
    }
}
 
开发者ID:MOLO17,项目名称:CustomizableCalendar,代码行数:19,代码来源:Calendar.java

示例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);
}
 
开发者ID:cbooy,项目名称:cakes,代码行数:26,代码来源:JodaTimeDemo1.java

示例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);
}
 
开发者ID:LineChen,项目名称:Month_Calendar,代码行数:11,代码来源:MonthCalendar.java

示例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();
}
 
开发者ID:LineChen,项目名称:Month_Calendar,代码行数:11,代码来源:MonthCalendar.java

示例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;
}
 
开发者ID:GoogleCloudPlatform,项目名称:dataflow-opinion-analysis,代码行数:10,代码来源:IndexerPipelineUtils.java

示例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);
}
 
开发者ID:pinterest,项目名称:soundwave,代码行数:9,代码来源:EsInstanceStore.java

示例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;
}
 
开发者ID:remipassmoilesel,项目名称:simple-hostel-management,代码行数:13,代码来源:Reservation.java

示例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;

}
 
开发者ID:LynnYuki,项目名称:CoolCloud-Weather,代码行数:41,代码来源:Time.java

示例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();

}
 
开发者ID:gvsucis,项目名称:mobile-app-dev-book,代码行数:11,代码来源:TripMapFragment.java

示例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());
}
 
开发者ID:IMSmobile,项目名称:Fahrplan,代码行数:6,代码来源:DatePickerFragment.java

示例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();
}
 
开发者ID:riteshakya037,项目名称:Android-Scrapper,代码行数:7,代码来源:ParseUtils.java


注:本文中的org.joda.time.DateTime.getMonthOfYear方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。