Java examples for java.time:Buddhist
get Now Thai Buddhist Date
//package com.java2s; import java.text.SimpleDateFormat; import java.time.chrono.ThaiBuddhistDate; import java.time.format.DateTimeFormatter; import java.util.Date; public class Main { public static final String DEFALUT_DATE_PATTERN = "dd-MMM-yyyy"; public static String getNowThaiBuddhistDate(String pattern) { String date = null;/*ww w .j av a 2 s . c o m*/ if (isNull(pattern)) { pattern = DEFALUT_DATE_PATTERN; } try { date = ThaiBuddhistDate.now().format( DateTimeFormatter.ofPattern(pattern)); } catch (Exception e) { } return date; } private static boolean isNull(String text) { return text == null || text.isEmpty(); } public static String format(Date date, String pattern) { SimpleDateFormat formatter = new SimpleDateFormat(pattern); return formatter.format(date); } }