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 List<String> getWeekDate() { List<String> list = new ArrayList<String>(); Calendar calendar = Calendar.getInstance(Locale.CHINA); calendar.setTime(new Date()); calendar.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); list.add(calendar.get(Calendar.MONTH) + 1 + "." + calendar.get(Calendar.DATE)); for (int i = 0; i < 6; i++) { calendar.add(Calendar.DATE, 1); String str = calendar.get(Calendar.MONTH) + 1 + "." + calendar.get(Calendar.DATE); list.add(str);//from ww w .ja va2 s . c o m } return list; }
From source file:Main.java
public static String getDateString(Date value, String format) { String result = null;// www. j a v a 2 s. c o m if (null != value) { SimpleDateFormat dateFormat = new SimpleDateFormat(format, Locale.CHINA); try { result = dateFormat.format(value); } catch (Exception e) { e.printStackTrace(); } } return result; }
From source file:Main.java
public static Date getDateByFormat(String strDate, String format) { SimpleDateFormat mSimpleDateFormat = new SimpleDateFormat(format, Locale.CHINA); Date date = null;/*from w w w .j a va 2 s .co m*/ try { date = mSimpleDateFormat.parse(strDate); } catch (ParseException e) { e.printStackTrace(); } return date; }
From source file:Main.java
/** * Return current timestamp with format "yyyyMMddHHmmss". *//*w w w. ja v a 2s . c o m*/ public static String getTimestamp() { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA); return dateFormat.format(new Date()); }
From source file:Main.java
private static String generateTimeTagMessageLog(String tag, String msg) { final String log = String.format("%s: %s: %s", SimpleDateFormat.getTimeInstance(DateFormat.DEFAULT, Locale.CHINA).format(new Date()), tag, msg); return log;/* w ww. j av a 2 s . com*/ }
From source file:Main.java
public static String getCurrentDateByOffset(String format, int calendarField, int offset) { String mDateTime = null;/*w w w . j av a2 s. com*/ try { SimpleDateFormat mSimpleDateFormat = new SimpleDateFormat(format, Locale.CHINA); Calendar c = Calendar.getInstance(); c.add(calendarField, offset); mDateTime = mSimpleDateFormat.format(c.getTime()); } catch (Exception e) { e.printStackTrace(); } return mDateTime; }
From source file:Main.java
/** * format Data like "yyyy-MM-dd"/*from w ww.j a v a 2 s . c o m*/ * * @param date * @return */ public static String parseDate(Date date) { if (date != null) { return new SimpleDateFormat("yyyy-MM-dd", Locale.CHINA).format(date); } else { return ""; } }
From source file:Main.java
public static String generatePlayTime(long time) { if (time % 1000 >= 500) { time += 1000;/* w ww . ja v a2 s .co m*/ } int totalSeconds = (int) (time / 1000); int seconds = totalSeconds % 60; int minutes = (totalSeconds / 60) % 60; int hours = totalSeconds / 3600; return hours > 0 ? String.format(Locale.CHINA, "%02d:%02d:%02d", hours, minutes, seconds) : String.format(Locale.CHINA, "%02d:%02d", minutes, seconds); }
From source file:Main.java
public static String parseDateToString(long lastModify) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(lastModify); Date date = calendar.getTime(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss", Locale.CHINA); String time = sdf.format(date); return time;/*from w w w . j a v a 2 s. c om*/ }
From source file:Main.java
public static String toDateString(String format) { return toDateString(Calendar.getInstance(Locale.CHINA).getTime(), format); }