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


Java LocalDateTime.getDayOfMonth方法代码示例

本文整理汇总了Java中java.time.LocalDateTime.getDayOfMonth方法的典型用法代码示例。如果您正苦于以下问题:Java LocalDateTime.getDayOfMonth方法的具体用法?Java LocalDateTime.getDayOfMonth怎么用?Java LocalDateTime.getDayOfMonth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.time.LocalDateTime的用法示例。


在下文中一共展示了LocalDateTime.getDayOfMonth方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: writeDateTimeUntil

import java.time.LocalDateTime; //导入方法依赖的package包/类
public static void writeDateTimeUntil(LocalDateTime dateTime, ByteArrayOutputStream bos) {
    // this is frigging confusing.. who the hell did think about this...
    // the first three bits are the months
    // next five bits are the day
    // next bit is always 0
    // next bit is the month again (the very first one)
    // next bit is always 0
    // last five bits are the year

    // only the first three bits!

    // int month = (positiveFirst >> 5 << 1) + (64 >> 6 & 1);
    int month = dateTime.getMonthValue();
    int monthAndDay = (month << 4 & 224) + dateTime.getDayOfMonth();
    bos.write(monthAndDay);

    int monthAndYear = (month % 2 == 1 ? 128 : 0) + (dateTime.getYear() - 2000);
    bos.write(monthAndYear);

    int halfhours = (dateTime.getHour() * 2) + (dateTime.getMinute() == 30 ? 1 : 0);
    bos.write(halfhours);
}
 
开发者ID:spinscale,项目名称:maxcube-java,代码行数:23,代码来源:Generator.java

示例2: javaToDosTime

import java.time.LocalDateTime; //导入方法依赖的package包/类
/**
 * Converts Java time to DOS time.
 */
private static long javaToDosTime(long time) {
    Instant instant = Instant.ofEpochMilli(time);
    LocalDateTime ldt = LocalDateTime.ofInstant(
            instant, ZoneId.systemDefault());
    int year = ldt.getYear() - 1980;
    if (year < 0) {
        return (1 << 21) | (1 << 16);
    }
    return (year << 25 |
        ldt.getMonthValue() << 21 |
        ldt.getDayOfMonth() << 16 |
        ldt.getHour() << 11 |
        ldt.getMinute() << 5 |
        ldt.getSecond() >> 1) & 0xffffffffL;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:ZipUtils.java

示例3: formatLocalName

import java.time.LocalDateTime; //导入方法依赖的package包/类
@SideOnly(Side.CLIENT)
public String formatLocalName(Component sub) {
    LocalDateTime time = LocalDateTime.now();
    if(time.getMonth() == Month.APRIL && time.getDayOfMonth() == 1) {
        return "April Fools!";
    }

    String format = I18n.format(RandoresKeys.FORMAT);
    String name = this.getName();
    String compName = sub.getLocalName();
    return format.replace("${name}", name).replace("${item}", compName);
}
 
开发者ID:Randores,项目名称:Randores2,代码行数:13,代码来源:MaterialDefinition.java

示例4: getNormalDate

import java.time.LocalDateTime; //导入方法依赖的package包/类
/**
 * Returns String representing given LocalDateTime.
 *
 * @param date to format
 * @return date as string
 */
public static String getNormalDate(LocalDateTime date, int type) {
    String returnString = date.getDayOfMonth() + " " + date.getMonth().toString().substring(0, 1).toUpperCase();
    return returnString + (type == SHORT_DATE ?
            date.getMonth().toString().substring(1, 3).toLowerCase() :
            date.getMonth().toString().substring(1).toLowerCase()) +
            " " + date.getYear();
}
 
开发者ID:kristenkotkas,项目名称:moviediary,代码行数:14,代码来源:StringUtils.java

示例5: dateFormatterForLogs

import java.time.LocalDateTime; //导入方法依赖的package包/类
private static String dateFormatterForLogs(LocalDateTime dateTime) {
    String dateString = "[";
    dateString += dateTime.getDayOfMonth() + "_";
    dateString += dateTime.getMonthValue() + "_";
    dateString += dateTime.getYear() + "_";
    dateString += dateTime.getHour() + ":";
    dateString += dateTime.getMinute() + ":";
    dateString += dateTime.getSecond();
    dateString += "] ";
    return dateString;
}
 
开发者ID:samurayrj,项目名称:rubenlagus-TelegramBots,代码行数:12,代码来源:FileFormatter.java

示例6: splitDatesIntoMonths

import java.time.LocalDateTime; //导入方法依赖的package包/类
public static List<Date[]> splitDatesIntoMonths(Date from, Date to) throws IllegalArgumentException {

    List<Date[]> dates = new ArrayList<>();

    LocalDateTime dFrom = asLocalDateTime(from);
    LocalDateTime dTo = asLocalDateTime(to);

    if (dFrom.compareTo(dTo) >= 0) {
      throw new IllegalArgumentException("Provide a to-date greater than the from-date");
    }

    while (dFrom.compareTo(dTo) < 0) {
      // check if current time frame is last
      boolean isLastTimeFrame = dFrom.getMonthValue() == dTo.getMonthValue() && dFrom.getYear() == dTo.getYear();

      // define day of month based on timeframe. if last - take boundaries from end date, else end of month and date
      int dayOfMonth = isLastTimeFrame ? dTo.getDayOfMonth() : dFrom.with(TemporalAdjusters.lastDayOfMonth()).getDayOfMonth();
      LocalTime time = isLastTimeFrame ? dTo.toLocalTime() : LocalTime.MAX;


      // build timeframe
      Date[] dar = new Date[2];
      dar[0] = asDate(dFrom);
      dar[1] = asDate(dFrom.withDayOfMonth(dayOfMonth).toLocalDate().atTime(time));

      // add current timeframe
      dates.add(dar);

      // jump to beginning of next month
      dFrom = dFrom.plusMonths(1).withDayOfMonth(1).toLocalDate().atStartOfDay();
    }

    return dates;

  }
 
开发者ID:YagelNasManit,项目名称:environment.monitor,代码行数:36,代码来源:DataUtils.java

示例7: getDateIdFromTimestamp

import java.time.LocalDateTime; //导入方法依赖的package包/类
public static int getDateIdFromTimestamp(long millis)
{
   	int result;
   	Instant i = Instant.ofEpochMilli(millis);
   	LocalDateTime ldt = LocalDateTime.ofInstant(i, ZoneId.of("UTC") ); //ZoneId.systemDefault()
   	int year = ldt.getYear();
   	int month = ldt.getMonth().getValue();
   	int day = ldt.getDayOfMonth();
   	result = day + (100 * month) + (10000 * year);
   	return result;
}
 
开发者ID:datancoffee,项目名称:sirocco,代码行数:12,代码来源:IdConverterUtils.java

示例8: decodeNotNull

import java.time.LocalDateTime; //导入方法依赖的package包/类
@Override
public Object decodeNotNull(int flag, CodecDataInput cdi) {
  long val = IntegerType.decodeNotNullPrimitive(flag, cdi);
  LocalDateTime localDateTime = fromPackedLong(val);
  if (localDateTime == null) {
    return null;
  }
  //TODO revisit this later.
  return new Date(localDateTime.getYear() - 1900,
      localDateTime.getMonthValue() - 1,
      localDateTime.getDayOfMonth());
}
 
开发者ID:pingcap,项目名称:tikv-client-lib-java,代码行数:13,代码来源:DateType.java

示例9: javaToDosTime

import java.time.LocalDateTime; //导入方法依赖的package包/类
public static long javaToDosTime(long time) {
    Instant instant = Instant.ofEpochMilli(time);
    LocalDateTime ldt = LocalDateTime.ofInstant(
            instant, ZoneId.systemDefault());
    int year = ldt.getYear() - 1980;
    if (year < 0) {
        return (1 << 21) | (1 << 16);
    }
    return (year << 25 |
        ldt.getMonthValue() << 21 |
        ldt.getDayOfMonth() << 16 |
        ldt.getHour() << 11 |
        ldt.getMinute() << 5 |
        ldt.getSecond() >> 1) & 0xffffffffL;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:ZipUtils.java

示例10: DateTimeParameterObject

import java.time.LocalDateTime; //导入方法依赖的package包/类
DateTimeParameterObject(final LocalDateTime localDateTime, @Nullable final String pattern) {
	this.localDateTime = localDateTime;
	this.pattern = Optional.ofNullable(pattern);
	this.dayOfMonth = localDateTime.getDayOfMonth();
	this.month = localDateTime.getMonthValue();
	this.year = localDateTime.getYear();
	this.hour = localDateTime.getHour();
	this.minute = localDateTime.getMinute();
	this.second = localDateTime.getSecond();
	this.instant = localDateTime.atZone(ZoneId.systemDefault()).toEpochSecond();
}
 
开发者ID:rooting-company,项目名称:roxana,代码行数:12,代码来源:DateTimeParameterObject.java

示例11: isNeededToLaunch

import java.time.LocalDateTime; //导入方法依赖的package包/类
/**
 * Vérifie si le batch doit être lancé grace a son schedul
 * 
 * @param batch
 * @param lastExec
 * @return true si le batch doit etre lance ou non
 */
private Boolean isNeededToLaunch(Batch batch, LocalDateTime lastExec) {
	/* Vérification si le batch doit etre lancé immediatement */
	if (batch.getTemIsLaunchImediaBatch()) {
		batch.setTemIsLaunchImediaBatch(false);
		batchRepository.saveAndFlush(batch);
		return true;
	}
	LocalDateTime now = LocalDateTime.now();

	/* Vérification si le batch doit etre lancé à une date précise */
	if (batch.getFixeYearBatch() != null && batch.getFixeMonthBatch() != null && batch.getFixeDayBatch() != null) {
		if (now.getYear() != batch.getFixeYearBatch() || now.getMonth().getValue() != batch.getFixeMonthBatch()
				|| now.getDayOfMonth() != batch.getFixeDayBatch()) {
			return false;
		}
	}
	/*
	 * Vérification si le batch doit etre lancé annuelement avec un mois donné et un
	 * jour donné
	 */
	if (batch.getFixeMonthBatch() != null && batch.getFixeDayBatch() != null) {
		if (now.getMonth().getValue() != batch.getFixeMonthBatch()
				|| now.getDayOfMonth() != batch.getFixeDayBatch()) {
			return false;
		}
	}
	/* Vérification si le batch doit etre lancé mensuelement avec un jour donné */
	else if (batch.getFixeDayBatch() != null) {
		if (now.getDayOfMonth() != batch.getFixeDayBatch()) {
			return false;
		}
	}

	/*
	 * Sinon vérification si le batch doit etre lancé hebdo avec les journs précisés
	 */
	else {
		DayOfWeek today = now.getDayOfWeek();
		if (!batch.getTemLundiBatch() && today.getValue() == 1) {
			return false;
		} else if (!batch.getTemMardiBatch() && today.getValue() == 2) {
			return false;
		} else if (!batch.getTemMercrBatch() && today.getValue() == 3) {
			return false;
		} else if (!batch.getTemJeudiBatch() && today.getValue() == 4) {
			return false;
		} else if (!batch.getTemVendrediBatch() && today.getValue() == 5) {
			return false;
		} else if (!batch.getTemSamediBatch() && today.getValue() == 6) {
			return false;
		} else if (!batch.getTemDimanBatch() && today.getValue() == 7) {
			return false;
		}
	}

	logger.trace("OK à lancer aujourd'hui");
	if ((batch.getFixeHourBatch().isAfter(lastExec.toLocalTime()))
			&& batch.getFixeHourBatch().isBefore(now.toLocalTime())) {
		logger.trace("OK à lancer maintenant");
		return true;
	}
	return false;
}
 
开发者ID:EsupPortail,项目名称:esup-ecandidat,代码行数:71,代码来源:BatchController.java

示例12: isAprilFools

import java.time.LocalDateTime; //导入方法依赖的package包/类
public static boolean isAprilFools() {
	LocalDateTime now = LocalDateTime.now();
	return now.getDayOfMonth()==1 && now.getMonth()==Month.APRIL;
}
 
开发者ID:elytra,项目名称:Thermionics,代码行数:5,代码来源:Thermionics.java

示例13: testDateTimeInfo

import java.time.LocalDateTime; //导入方法依赖的package包/类
/**
 * 获取时间节点的详细信息
 */
@Test
public void testDateTimeInfo(){
    LocalDateTime ldt = LocalDateTime.now();

    // 获取当前的年份
    int year = ldt.getYear();
    System.out.println(year);

    // 当前年中的第几天
    int dayOfYear = ldt.getDayOfYear();
    System.out.println(dayOfYear);

    // 当前月份中的第几天
    int dayOfMonth = ldt.getDayOfMonth();
    System.out.println(dayOfMonth);

    // 当前周中的第几天
    DayOfWeek dayOfWeek = ldt.getDayOfWeek();
    int dayOfWeekValue = dayOfWeek.getValue();
    System.out.println(dayOfWeekValue);

    // 获取小时
    int hour = ldt.getHour();
    System.out.println(hour);

    // 获取月份信息
    Month month = ldt.getMonth();
    int monthValue = month.getValue();
    System.out.println(monthValue);
    int ldtMonthValue = ldt.getMonthValue();
    System.out.println(ldtMonthValue);

    // 获取分钟
    int minute = ldt.getMinute();
    System.out.println(minute);
}
 
开发者ID:cbooy,项目名称:cakes,代码行数:40,代码来源:LocalDateTimeDemo.java

示例14: valueOf

import java.time.LocalDateTime; //导入方法依赖的package包/类
/**
 * Obtains an instance of {@code Timestamp} from a {@code LocalDateTime}
 * object, with the same year, month, day of month, hours, minutes,
 * seconds and nanos date-time value as the provided {@code LocalDateTime}.
 * <p>
 * The provided {@code LocalDateTime} is interpreted as the local
 * date-time in the local time zone.
 *
 * @param dateTime a {@code LocalDateTime} to convert
 * @return a {@code Timestamp} object
 * @exception NullPointerException if {@code dateTime} is null.
 * @since 1.8
 */
@SuppressWarnings("deprecation")
public static Timestamp valueOf(LocalDateTime dateTime) {
    return new Timestamp(dateTime.getYear() - 1900,
                         dateTime.getMonthValue() - 1,
                         dateTime.getDayOfMonth(),
                         dateTime.getHour(),
                         dateTime.getMinute(),
                         dateTime.getSecond(),
                         dateTime.getNano());
}
 
开发者ID:madHEYsia,项目名称:ClassroomFlipkart,代码行数:24,代码来源:Timestamp.java


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