本文整理匯總了Java中java.util.Locale.US屬性的典型用法代碼示例。如果您正苦於以下問題:Java Locale.US屬性的具體用法?Java Locale.US怎麽用?Java Locale.US使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類java.util.Locale
的用法示例。
在下文中一共展示了Locale.US屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setDate
/**
* Set a parameter to a java.sql.Date value. The driver converts this to a
* SQL DATE value when it sends it to the database.
*
* @param parameterIndex
* the first parameter is 1, the second is 2, ...
* @param x
* the parameter value
* @param cal
* the calendar to interpret the date with
*
* @exception SQLException
* if a database-access error occurs.
*/
public void setDate(int parameterIndex, java.sql.Date x, Calendar cal) throws SQLException {
if (x == null) {
setNull(parameterIndex, java.sql.Types.DATE);
} else {
if (!this.useLegacyDatetimeCode) {
newSetDateInternal(parameterIndex, x, cal);
} else {
synchronized (checkClosed().getConnectionMutex()) {
if (this.ddf == null) {
this.ddf = new SimpleDateFormat("''yyyy-MM-dd''", Locale.US);
}
if (cal != null) {
this.ddf.setTimeZone(cal.getTimeZone());
}
setInternal(parameterIndex, this.ddf.format(x));
this.parameterTypes[parameterIndex - 1 + getParameterIndexOffset()] = Types.DATE;
}
}
}
}
示例2: newSetDateInternal
private void newSetDateInternal(int parameterIndex, Date x, Calendar targetCalendar) throws SQLException {
synchronized (checkClosed().getConnectionMutex()) {
if (this.ddf == null) {
this.ddf = new SimpleDateFormat("''yyyy-MM-dd''", Locale.US);
}
if (targetCalendar != null) {
this.ddf.setTimeZone(targetCalendar.getTimeZone());
} else if (this.connection.getNoTimezoneConversionForDateType()) {
this.ddf.setTimeZone(this.connection.getDefaultTimeZone());
} else {
this.ddf.setTimeZone(this.connection.getServerTimezoneTZ());
}
setInternal(parameterIndex, this.ddf.format(x));
}
}
示例3: doubleToString
/**
* Locale-dependently converts a double into a string.
*
* @param decimal a double
* @return the user's locale's representation of the given double
*/
private static String doubleToString(final double decimal) {
final Locale locale = Locale.US;
final NumberFormat formatter = NumberFormat.getInstance(locale);
return formatter.format(decimal);
}
示例4: formatDate
private static String formatDate(String rawDate) {
String jsonDatePattern = "yyyy-MM-dd'T'HH:mm:ss'Z'";
SimpleDateFormat jsonFormatter = new SimpleDateFormat(jsonDatePattern, Locale.US);
try {
Date parsedJsonDate = jsonFormatter.parse(rawDate);
String finalDatePattern = "MMM d, yyy";
SimpleDateFormat finalDateFormatter = new SimpleDateFormat(finalDatePattern, Locale.US);
return finalDateFormatter.format(parsedJsonDate);
} catch (ParseException e) {
Log.e("QueryUtils", "Error parsing JSON date: ", e);
return "";
}
}
示例5: getFormat
public SimpleDateFormat getFormat() {
String format = getProperty(OTAConfig.VERSION_FORMAT, "");
if (format.isEmpty()) {
return null;
}
try {
return new SimpleDateFormat(format, Locale.US);
} catch (IllegalArgumentException | NullPointerException e) {
OTAUtils.logError(e);
}
return null;
}
示例6: getDateCompartor
static Comparator<UserNote> getDateCompartor() {
return (o1, o2) -> {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US);
try {
return sdf.parse(o1.timeStampString).compareTo(sdf.parse(o2.timeStampString));
} catch (ParseException e) {
e.printStackTrace();
return 0;
}
};
}
示例7: initialValue
@Override
protected SimpleDateFormat[] initialValue() {
return new SimpleDateFormat[] {
new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US),
new SimpleDateFormat("EEEEEE, dd-MMM-yy HH:mm:ss zzz", Locale.US),
new SimpleDateFormat("EEE MMMM d HH:mm:ss yyyy", Locale.US)
};
}
示例8: newSetTimeInternal
private void newSetTimeInternal(int parameterIndex, Time x, Calendar targetCalendar) throws SQLException {
synchronized (checkClosed().getConnectionMutex()) {
if (this.tdf == null) {
this.tdf = new SimpleDateFormat("''HH:mm:ss''", Locale.US);
}
if (targetCalendar != null) {
this.tdf.setTimeZone(targetCalendar.getTimeZone());
} else {
this.tdf.setTimeZone(this.connection.getServerTimezoneTZ());
}
setInternal(parameterIndex, this.tdf.format(x));
}
}
示例9: toString
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
Formatter f = new Formatter(sb, Locale.US);
f.format("=== Types ===%n");
f.format("%s%n", types.toString());
f.format("=== Methods ===%n");
f.format("%s%n", methods.toString());
f.format("=== Fields ===%n");
f.format("%s%n", fields.toString());
return sb.toString();
}
示例10: initialValue
protected DateFormat initialValue() {
DateFormat df =
new SimpleDateFormat(OLD_COOKIE_PATTERN, Locale.US);
df.setTimeZone(TimeZone.getTimeZone("GMT"));
return df;
}
示例11: send
/**
* Sends given response to the socket.
*/
private void send(OutputStream outputStream) {
String mime = mimeType;
SimpleDateFormat gmtFrmt = new SimpleDateFormat(
"E, d MMM yyyy HH:mm:ss 'GMT'", Locale.US);
gmtFrmt.setTimeZone(TimeZone.getTimeZone("GMT"));
try {
if (status == null) {
throw new Error("sendResponse(): Status can't be null.");
}
PrintWriter pw = new PrintWriter(outputStream);
pw.print("HTTP/1.0 " + status.getDescription() + " \r\n");
if (mime != null) {
pw.print("Content-Type: " + mime + "\r\n");
}
if (header == null || header.get("Date") == null) {
pw.print("Date: " + gmtFrmt.format(new Date()) + "\r\n");
}
if (header != null) {
for (String key : header.keySet()) {
String value = header.get(key);
pw.print(key + ": " + value + "\r\n");
}
}
pw.print("\r\n");
pw.flush();
if (data != null) {
int pending = data.available(); // This is to support
// partial sends, see
// serveFile()
int BUFFER_SIZE = 16 * 1024;
byte[] buff = new byte[BUFFER_SIZE];
while (pending > 0) {
int read = data.read(buff, 0,
((pending > BUFFER_SIZE) ? BUFFER_SIZE
: pending));
if (read <= 0) {
break;
}
outputStream.write(buff, 0, read);
pending -= read;
}
}
outputStream.flush();
outputStream.close();
if (data != null)
data.close();
} catch (IOException ioe) {
// Couldn't write? No can do.
}
}
示例12: getTimeFormat
public static DateFormat getTimeFormat() {
return new SimpleDateFormat(TIME_FORMAT_PATTERN, Locale.US);
}
示例13: Logger
protected Logger() {
mDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS", Locale.US);
}
示例14: main
public static void main(String[] a) throws Exception {
// DRBackendTidsformater.servertidsformat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.US); // +01:00 springes over da kolon i +01:00 er ikke-standard Java
parseUpålideigtServertidsformat("2014-02-13T10:03:00+01:00");
DRBackendTidsformater.servertidsformat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssz", Locale.US); // +01:00 springes over da kolon i +01:00 er ikke-standard Java
System.out.println("res = "+ parseUpålideigtServertidsformat("2017-03-27T04:00:35+0000"));
}
示例15: initialValue
@Override
public DateFormat initialValue() {
DateFormat result = new SimpleDateFormat(asctimePattern, Locale.US);
result.setTimeZone(GMT_ZONE);
return result;
}