List of usage examples for java.util Locale CHINA
Locale CHINA
To view the source code for java.util Locale CHINA.
Click Source Link
From source file:Main.java
public static String toDateString(Date date, String format) { SimpleDateFormat sdf = new SimpleDateFormat(format, Locale.CHINA); return sdf.format(date); }
From source file:Main.java
public static boolean hasLocalChina() { boolean has = false; Locale locale[] = Locale.getAvailableLocales(); for (int i = 0; i < locale.length; i++) { if (locale[i].equals(Locale.CHINA)) { has = true;//from w ww .ja va 2s .co m break; } } return has; }
From source file:Main.java
public static String getCurrentDate() { return DateFormat.format("yyyyMMdd_hhmmss", Calendar.getInstance(Locale.CHINA)).toString(); }
From source file:Main.java
public static String formatToDate(String datetime) { String str = ""; SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd", Locale.CHINA); try {//from www . ja va 2 s . c o m str = format.format(format.parse(datetime)); } catch (ParseException e) { e.printStackTrace(); } return str; }
From source file:Main.java
public static int getWeekNum() { int num = 1;//from w w w . j ava 2s. co m try { SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA); long to = new Date().getTime(); long from = df.parse("2014-9-8 00:00:00").getTime(); num = (int) Math.ceil((to - from) * 1.0 / (1000 * 60 * 60 * 24) / 7.0); } catch (Exception e) { e.printStackTrace(); } return num; }
From source file:Main.java
public static String getCurrentTime() { Calendar currentTime = Calendar.getInstance(); SimpleDateFormat dateformat = new SimpleDateFormat("HH:mm", Locale.CHINA); String timeLableStr = dateformat.format(currentTime.getTime()); return timeLableStr; }
From source file:Main.java
public static int compare(String s1, String s2) { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA); try {//from w w w . j a va2s. co m Date d1 = format.parse(s1); Date d2 = format.parse(s2); return d1.compareTo(d2); } catch (ParseException e) { e.printStackTrace(); } return -1; }
From source file:Main.java
public static String getTimeStamp(String time) { SimpleDateFormat sdr = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss", Locale.CHINA); Date date;//ww w. ja v a 2s . c om String times = null; try { date = sdr.parse(time); long l = date.getTime(); String stf = String.valueOf(l); times = stf.substring(0, 10); } catch (ParseException e) { e.printStackTrace(); } return times; }
From source file:Main.java
/** * ??????????/*from ww w. java2 s . c o m*/ * * @param date * @return */ public static String getShortDate(Date date) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd", Locale.CHINA); return sdf.format(date); }
From source file:Main.java
public static long formatToLong(String time, String template) { SimpleDateFormat sdf = new SimpleDateFormat(template, Locale.CHINA); try {/*from ww w. j a v a 2 s . c o m*/ Date d = sdf.parse(time); Calendar c = Calendar.getInstance(); c.setTime(d); long l = c.getTimeInMillis(); return l; } catch (ParseException e) { e.printStackTrace(); return 0; } }