我是靠谱客的博主 顺心方盒,这篇文章主要介绍java短信动态模板MessageFormat,现在分享给大家,希望可以做个参考。

这个可以用在很多地方,比如短信、邮件的消息。用法如下:public static void main(String[] args) { String info = "{0}您好,欢迎来到{1},n记…
这个可以用在很多地方,比如短信、邮件的消息。

用法如下:

String pattern1 = "尊敬的 {0} 先生/女士 ,欢迎您预约贝壳找房平台看房,您的管家 {1} 手机号是 {2} 看房时间:{3} ,已经预约通过,请等待管家联系您";
String pattern2 = "At {3,time,short} on {3,date,long}";
Object[] params = {"hoonick","李明","55555555",new Date()};
//使用默认的本地化对象格式化字符串
String format = MessageFormat.format(pattern1, params);
System.out.println(format);
 //使用指定的本地化对象格式化字符串
MessageFormat mf = new MessageFormat(pattern2, Locale.US);
String format2 = mf.format(params);
System.out.println(format2);

动态调用模板

String message=MessageFormat.format(hsMessageTemplate.getTemplateMessage(),hsHousekeepers.getHousekeeper()); 

String phone=appointmentVo.getAppointmentTelphone();
System.out.println(message);
SmsAli smsUtil = new SmsAli();  调用短信配置文件发送短信
msUtil.smsUtil(phone,message);

最后

以上就是顺心方盒最近收集整理的关于java短信动态模板MessageFormat的全部内容,更多相关java短信动态模板MessageFormat内容请搜索靠谱客的其他文章。

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

评论列表共有 0 条评论

立即
投稿
返回
顶部