简单工厂代码

简单工厂代码,第1张

简单工厂代码

import java.text.DateFormat;
import java.text.NumberFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;

import org.junit.Test;



public class SimpleFactoryDemo {
	@Test
	protected void method1() {
		//介绍几个简单工厂案例。
		DateFormat dateFormat=DateFormat.getInstance();
		Date date=new Date();
		System.out.println(dateFormat.format(date)+"n");
		
		
		
		//这些都是一个工厂方法。你可以点击源码去看。
		System.out.println(LocalDate.now());


		System.out.println(LocalDateTime.now().hashCode());
		System.out.println(LocalDateTime.now().hashCode());
		System.out.println(LocalDateTime.now());
		System.out.println(LocalDateTime.now());
		System.out.println(LocalDateTime.now());

		
		NumberFormat numberFormat=NumberFormat.getInstance();
		NumberFormat PercentFormat=NumberFormat.getPercentInstance();
		double num=2.3;
		System.out.println(numberFormat.format(num)+"n"+PercentFormat.format(num));
	}
}

	

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5709152.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-17
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存