List of usage examples for java.util Locale getDefault
public static Locale getDefault()
From source file:Main.java
public static String TimestampJavaToDateSQLlite(Timestamp date) { if (date != null) { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault()); return dateFormat.format(date); } else// w w w . j av a 2 s. c o m return null; }
From source file:Main.java
public static byte[] hexStringToBytes(String hexString) { if (hexString == null || hexString.equals("")) { return null; }/*from w w w. jav a2 s. c o m*/ hexString = hexString.toUpperCase(Locale.getDefault()); int length = hexString.length() / 2; char[] hexChars = hexString.toCharArray(); byte[] d = new byte[length]; for (int i = 0; i < length; i++) { int pos = i * 2; d[i] = (byte) (charToByte(hexChars[pos]) << 4 | charToByte(hexChars[pos + 1])); } return d; }
From source file:Main.java
public static String getStringDateFromTimeStamp(long timeStamp, String format) { // "ddd MM, yyyy" DateFormat sdf = new SimpleDateFormat(format, Locale.getDefault()); Date netDate = (new Date(timeStamp * 1000)); return sdf.format(netDate); }
From source file:Main.java
public static Date convertDateStringToDate(String dateString) throws ParseException { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault()); // dateFormat.setLenient(true); return dateFormat.parse(dateString); }
From source file:Main.java
public static Calendar dateUSToCalendar(String data) throws ParseException { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()); Date date = sdf.parse(data);//from w ww . j a va2 s. c om Calendar calendar = Calendar.getInstance(); calendar.setTime(date); return calendar; }
From source file:Main.java
public static String getWeekDay(int position) { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.DAY_OF_WEEK, position + 1); return calendar.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.SHORT, Locale.getDefault()); }
From source file:Main.java
public static Calendar dateShortBrToCalendar(String data) throws ParseException { SimpleDateFormat sdf = new SimpleDateFormat("MMM/yyyy", Locale.getDefault()); Date date = sdf.parse(data);/* w w w .j av a 2 s .co m*/ Calendar calendar = Calendar.getInstance(); calendar.setTime(date); return calendar; }
From source file:Main.java
public static String dateParse(long timeStampInMilliSeconds) { DateFormat df = new SimpleDateFormat("dd-MM-yyyy HH:mm", Locale.getDefault()); Date d = new Date(timeStampInMilliSeconds); return df.format(d); }
From source file:Main.java
public static String toHHMM(Calendar source) { if (source == null) { return "Can't HH:mm, source null"; }//w ww. j av a 2 s.c o m SimpleDateFormat sdf = new SimpleDateFormat("HH:mm", Locale.getDefault()); //SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss", Locale.getDefault()); String strDate = sdf.format(source.getTime()); return strDate; }
From source file:Main.java
public static String formatDayAndMonth(long date) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat(FORMAT_DAY_OF_MONTH, Locale.getDefault()); return simpleDateFormat.format(new Date((long) 1444897963)); }