我是靠谱客的博主 友好金针菇,最近开发中收集的这篇文章主要介绍练习java文档MonthDay,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

MonthDay
adjustInto()涉及到Temporal先放着
atYear()
compareTo()也是返回差值
equals()也是时间相等就返回true
format()
from()涉及到TemporalAccessor先放着
get()涉及到TemporalField先放着
getDayOfMonth()
getLong()涉及到TemporalField先放着
getMonth()
getMonthValue()
hashCode() 一个月是64,一天是1
isAfter()
isBefore()
isSupported()涉及到TemporalField先放着
isValidYear()
now()
of()
parse() --12-02
query()涉及到TemporalQuery先放着
range()涉及到TemporalField先放着
toString()
with()
withDayOfMonth()
withMonth()

import java.util.function.*;
import java.util.stream.*;
import java.util.*;
import java.math.*;
import static  java.util.Calendar.*;
import java.time.*;
import java.time.format.*;
import java.time.chrono.*;
import java.time.temporal.*;
public class Test
{
	public static void main(String[] args) throws Exception
	{

		//先练书上的例子
		//MonthDay
		var md = MonthDay.now();
		System.out.println("当前月日:"+md);
		var md2 = md.with(Month.MAY).withDayOfMonth(23);
		System.out.println("5月23日为:"+md2);

		md = MonthDay.now();
		LocalDate localDate = md.atYear(1111);
		System.out.println(localDate);

		MonthDay md1 = MonthDay.of(11,11);
		md2 = MonthDay.of(11,11);
		System.out.println(md1.compareTo(md2));
		System.out.println(md1.equals(md2));

		md = MonthDay.of(11,2);
		System.out.println(md.format(DateTimeFormatter.ofPattern("MM月dd日")));
		System.out.println(md.getDayOfMonth());

		md = MonthDay.now();
		System.out.println(md.getMonth());
		System.out.println(md.getMonthValue());

		md =MonthDay.of(10,1);
		md1 = MonthDay.of(10,2);
		System.out.println(md.hashCode());
		System.out.println(md1.hashCode());
		
		System.out.println(md.isAfter(md1));
		System.out.println(md.isBefore(md1));

		md = MonthDay.of(2,29);
		System.out.println(md.isValidYear(2000));
		System.out.println(md.isValidYear(2001));

		md = MonthDay.now();
		System.out.println(md);
		Clock clock = Clock.systemUTC();
		md = MonthDay.now(clock);
		System.out.println(md);
		ZoneId zid = ZoneId.systemDefault();
		md = MonthDay.now(zid);	
		System.out.println(md);

		md = MonthDay.of(11,1);
		System.out.println(md);
		md = MonthDay.of(Month.MARCH, 1);
		System.out.println(md);

		md = MonthDay.parse("--03-02");
		System.out.println(md);

		md = MonthDay.parse("02月07日",DateTimeFormatter.ofPattern("MM月dd日"));
		System.out.println(md);
		System.out.println(md.toString());

		md = MonthDay.now();
		System.out.println(md);
		md = md.with(Month.MAY);
		System.out.println(md);

		md = MonthDay.now();
		md = md.withDayOfMonth(2);
		System.out.println(md);	
		md = md.withMonth(1);	
		System.out.println(md);
	}
	
}

最后

以上就是友好金针菇为你收集整理的练习java文档MonthDay的全部内容,希望文章能够帮你解决练习java文档MonthDay所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(51)

评论列表共有 0 条评论

立即
投稿
返回
顶部