java.util.Locale#ENGLISH源码实例Demo

下面列出了java.util.Locale#ENGLISH 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: wildfly-core   文件: MavenUtil.java
@Override
public void transferSucceeded(TransferEvent event) {
    transferCompleted(event);

    TransferResource resource = event.getResource();
    long contentLength = event.getTransferredBytes();
    if (contentLength >= 0) {
        String type = (event.getRequestType() == TransferEvent.RequestType.PUT ? "Uploaded" : "Downloaded");
        String len = contentLength >= 1024 ? toKB(contentLength) + " KB" : contentLength + " B";

        String throughput = "";
        long duration = System.currentTimeMillis() - resource.getTransferStartTime();
        if (duration > 0) {
            DecimalFormat format = new DecimalFormat("0.0", new DecimalFormatSymbols(Locale.ENGLISH));
            double kbPerSec = (contentLength / 1024.0) / (duration / 1000.0);
            throughput = " at " + format.format(kbPerSec) + " KB/sec";
        }

        log.debug(type + ": " + resource.getRepositoryUrl() + resource.getResourceName() + " (" + len + throughput
                + ")");
    }
}
 
源代码2 项目: olingo-odata4   文件: DemoEntityProcessor.java
@Override
public void readMediaEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType responseFormat)
    throws ODataApplicationException, ODataLibraryException {
  
  final UriResource firstResoucePart = uriInfo.getUriResourceParts().get(0);
  if(firstResoucePart instanceof UriResourceEntitySet) {
    final EdmEntitySet edmEntitySet = Util.getEdmEntitySet(uriInfo);
    final UriResourceEntitySet uriResourceEntitySet = (UriResourceEntitySet) firstResoucePart;
    
    final Entity entity = storage.readEntityData(edmEntitySet, uriResourceEntitySet.getKeyPredicates());
    if(entity == null) {
      throw new ODataApplicationException("Entity not found", HttpStatusCode.NOT_FOUND.getStatusCode(), 
          Locale.ENGLISH);
    }

    final byte[] mediaContent = storage.readMedia(entity);
    final InputStream responseContent = odata.createFixedFormatSerializer().binary(mediaContent);
    
    response.setStatusCode(HttpStatusCode.OK.getStatusCode());
    response.setContent(responseContent);
    response.setHeader(HttpHeader.CONTENT_TYPE, entity.getMediaContentType());
  } else {
    throw new ODataApplicationException("Not implemented", HttpStatusCode.BAD_REQUEST.getStatusCode(), 
        Locale.ENGLISH);
  }
}
 
源代码3 项目: micro-integrator   文件: ODataAdapter.java
@Override
public void createEntity(DataRequest request, Entity entity, EntityResponse response)
        throws ODataApplicationException {
    EdmEntitySet edmEntitySet = request.getEntitySet();
    String baseURL = request.getODataRequest().getRawBaseUri();
    try {
        Entity created = createEntityInTable(edmEntitySet.getEntityType(), entity);
        entity.setId(new URI(ODataUtils.buildLocation(baseURL, created, edmEntitySet.getName(),
                                                      edmEntitySet.getEntityType())));
        response.writeCreatedEntity(edmEntitySet, created);
    } catch (ODataServiceFault | SerializerException | URISyntaxException | EdmPrimitiveTypeException e) {
        response.writeNotModified();
        String error = "Error occurred while creating entity. :" + e.getMessage();
        throw new ODataApplicationException(error, 500, Locale.ENGLISH);
    }
}
 
@Test
public void resolveViewNameAcceptHeaderSortByQuality() throws Exception {
	request.addHeader("Accept", "text/plain;q=0.5, application/json");

	viewResolver.setContentNegotiationManager(new ContentNegotiationManager(new HeaderContentNegotiationStrategy()));

	ViewResolver htmlViewResolver = mock(ViewResolver.class);
	ViewResolver jsonViewResolver = mock(ViewResolver.class);
	viewResolver.setViewResolvers(Arrays.asList(htmlViewResolver, jsonViewResolver));

	View htmlView = mock(View.class, "text_html");
	View jsonViewMock = mock(View.class, "application_json");

	String viewName = "view";
	Locale locale = Locale.ENGLISH;

	given(htmlViewResolver.resolveViewName(viewName, locale)).willReturn(htmlView);
	given(jsonViewResolver.resolveViewName(viewName, locale)).willReturn(jsonViewMock);
	given(htmlView.getContentType()).willReturn("text/html");
	given(jsonViewMock.getContentType()).willReturn("application/json");

	View result = viewResolver.resolveViewName(viewName, locale);
	assertSame("Invalid view", jsonViewMock, result);
}
 
源代码5 项目: msf4j   文件: HttpHeadersImpl.java
@Override
public Date getDate() {
    String value = nettyHttpHeaders.get(HttpHeaders.DATE);
    if (value == null || value.isEmpty()) {
        return null;
    }
    // Preferred date format in internet standard is Sun, 06 Nov 1994 08:49:37 GMT
    SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT_PATTERN, Locale.ENGLISH);
    //All HTTP date/time stamps MUST be represented in Greenwich Mean Time (GMT)
    dateFormat.setTimeZone(TimeZone.getTimeZone(GMT_TIMEZONE));
    try {
        return dateFormat.parse(value);
    } catch (ParseException e) {
        log.error("Error while parsing the Date value. Hence return null", e);
        return null;
    }
}
 
源代码6 项目: buck   文件: DirtyPrintStreamDecoratorTest.java
@Test
public void testPrintfWithLocale() {
  Locale locale = Locale.ENGLISH;
  String formatString = "Build target [%s] does not exist.";
  String greeter = "//foo:bar";
  PrintStream delegate =
      new PrintStream(new ByteArrayOutputStream()) {
        @Override
        public PrintStream printf(Locale l, String format, Object... args) {
          assertEquals(locale, l);
          assertEquals(format, formatString);
          assertEquals(args[0], greeter);
          return this;
        }
      };

  DirtyPrintStreamDecorator dirtyPrintStream = new DirtyPrintStreamDecorator(delegate);
  PrintStream valueToChain = dirtyPrintStream.printf(locale, formatString, greeter);

  assertEquals(dirtyPrintStream, valueToChain);
  assertTrue(dirtyPrintStream.isDirty());
}
 
源代码7 项目: Bytecoder   文件: Finished.java
@Override
public String toString() {
    MessageFormat messageFormat = new MessageFormat(
            "\"Finished\": '{'\n" +
            "  \"verify data\": '{'\n" +
            "{0}\n" +
            "  '}'" +
            "'}'",
            Locale.ENGLISH);

    HexDumpEncoder hexEncoder = new HexDumpEncoder();
    Object[] messageFields = {
            Utilities.indent(hexEncoder.encode(verifyData), "    "),
        };
    return messageFormat.format(messageFields);
}
 
源代码8 项目: openjsse   文件: RSAServerKeyExchange.java
@Override
public String toString() {
    MessageFormat messageFormat = new MessageFormat(
        "\"RSA ServerKeyExchange\": '{'\n" +
        "  \"parameters\": '{'\n" +
        "    \"rsa_modulus\": '{'\n" +
        "{0}\n" +
        "    '}',\n" +
        "    \"rsa_exponent\": '{'\n" +
        "{1}\n" +
        "    '}'\n" +
        "  '}',\n" +
        "  \"digital signature\":  '{'\n" +
        "    \"signature\": '{'\n" +
        "{2}\n" +
        "    '}',\n" +
        "  '}'\n" +
        "'}'",
        Locale.ENGLISH);

    HexDumpEncoder hexEncoder = new HexDumpEncoder();
    Object[] messageFields = {
        Utilities.indent(
                hexEncoder.encodeBuffer(modulus), "      "),
        Utilities.indent(
                hexEncoder.encodeBuffer(exponent), "      "),
        Utilities.indent(
                hexEncoder.encodeBuffer(paramsSignature), "      ")
    };
    return messageFormat.format(messageFields);
}
 
源代码9 项目: hottub   文件: AbstractTestPrinterParser.java
@BeforeMethod
public void setUp() {
    buf = new StringBuilder();
    builder = new DateTimeFormatterBuilder();
    dta = ZonedDateTime.of(LocalDateTime.of(2011, 6, 30, 12, 30, 40, 0), ZoneId.of("Europe/Paris"));
    locale = Locale.ENGLISH;
    decimalStyle = DecimalStyle.STANDARD;
}
 
源代码10 项目: blessed-android   文件: MainActivity.java
@Override
public void onReceive(Context context, Intent intent) {
    TemperatureMeasurement measurement = (TemperatureMeasurement) intent.getSerializableExtra("Temperature");
    if (measurement == null) return;

    DateFormat df = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss", Locale.ENGLISH);
    String formattedTimestamp = df.format(measurement.timestamp);
    measurementValue.setText(String.format(Locale.ENGLISH, "%.1f %s (%s)\n%s", measurement.temperatureValue, measurement.unit == TemperatureUnit.Celsius ? "celcius" : "fahrenheit", measurement.type, formattedTimestamp));
}
 
源代码11 项目: yuzhouwan   文件: GroupTry.java
@Test
public void testDateFormat2() {
    String str = "1 17:07:42:807 2016";
    SimpleDateFormat sdf = new SimpleDateFormat("d HH:mm:ss:SSS yyyy", Locale.ENGLISH);
    try {
        System.out.println(sdf.parse(str));
    } catch (ParseException e) {
        throw new RuntimeException(e);
    }
}
 
@Test
public void resolveViewNameFilenameDefaultView() throws Exception {
	request.setRequestURI("/test.json");

	Map<String, MediaType> mapping = Collections.singletonMap("json", MediaType.APPLICATION_JSON);
	PathExtensionContentNegotiationStrategy pathStrategy = new PathExtensionContentNegotiationStrategy(mapping);
	viewResolver.setContentNegotiationManager(new ContentNegotiationManager(pathStrategy));

	ViewResolver viewResolverMock1 = mock(ViewResolver.class);
	ViewResolver viewResolverMock2 = mock(ViewResolver.class);
	viewResolver.setViewResolvers(Arrays.asList(viewResolverMock1, viewResolverMock2));

	View viewMock1 = mock(View.class, "application_xml");
	View viewMock2 = mock(View.class, "text_html");
	View viewMock3 = mock(View.class, "application_json");

	List<View> defaultViews = new ArrayList<View>();
	defaultViews.add(viewMock3);
	viewResolver.setDefaultViews(defaultViews);

	viewResolver.afterPropertiesSet();

	String viewName = "view";
	Locale locale = Locale.ENGLISH;

	given(viewResolverMock1.resolveViewName(viewName, locale)).willReturn(viewMock1);
	given(viewResolverMock1.resolveViewName(viewName + ".json", locale)).willReturn(null);
	given(viewResolverMock2.resolveViewName(viewName, locale)).willReturn(viewMock2);
	given(viewResolverMock2.resolveViewName(viewName + ".json", locale)).willReturn(null);
	given(viewMock1.getContentType()).willReturn("application/xml");
	given(viewMock2.getContentType()).willReturn("text/html;charset=ISO-8859-1");
	given(viewMock3.getContentType()).willReturn("application/json");

	View result = viewResolver.resolveViewName(viewName, locale);
	assertSame("Invalid view", viewMock3, result);
}
 
源代码13 项目: PocketEOS-Android   文件: LocalManageUtil.java
/**
 * 获取选择的语言设置
 *
 * @param context
 * @return
 */
public static Locale getSetLanguageLocale(Context context) {

    switch (SPUtil.getInstance(context).getSelectLanguage()) {
        case 0:
            return getSystemLocale(context);
        case 1:
            return Locale.CHINA;
        case 2:
        default:
            return Locale.ENGLISH;
    }
}
 
@Override
public String getFormattedValue(float value, AxisBase axis) {
    if (value >= labels.size()) {
        return "";
    }
    DateFormat df = new SimpleDateFormat("HH:mm", Locale.ENGLISH);
    Calendar cal = Calendar.getInstance();
    cal.setTimeInMillis(Long.parseLong(labels.get((int) value)));
    return (df.format(cal.getTime()));
}
 
源代码15 项目: RipplePower   文件: CalendarParsedResult.java
private static DateFormat buildDateFormat() {
	DateFormat format = new SimpleDateFormat("yyyyMMdd", Locale.ENGLISH);
	// For dates without a time, for purposes of interacting with Android,
	// the resulting timestamp
	// needs to be midnight of that day in GMT. See:
	// http://code.google.com/p/android/issues/detail?id=8330
	format.setTimeZone(TimeZone.getTimeZone("GMT"));
	return format;
}
 
源代码16 项目: conference-app   文件: MainAdapter.java
public MainAdapter(Context context, List<Conference> objects) {
    mData = objects;
    mContext = context.getApplicationContext();
    simpleDateFormat = new SimpleDateFormat("HH:mm", Locale.ENGLISH);
    simpleDateFormat2 = new SimpleDateFormat(" - HH:mm", Locale.ENGLISH);
}
 
源代码17 项目: astor   文件: DateUtilsTest.java
@Before
public void setUp() throws Exception {


    dateParser = new SimpleDateFormat("MMM dd, yyyy", Locale.ENGLISH);
    dateTimeParser = new SimpleDateFormat("MMM dd, yyyy H:mm:ss.SSS", Locale.ENGLISH);

    dateAmPm1 = dateTimeParser.parse("February 3, 2002 01:10:00.000");
    dateAmPm2 = dateTimeParser.parse("February 3, 2002 11:10:00.000");
    dateAmPm3 = dateTimeParser.parse("February 3, 2002 13:10:00.000");
    dateAmPm4 = dateTimeParser.parse("February 3, 2002 19:10:00.000");
    date0 = dateTimeParser.parse("February 3, 2002 12:34:56.789");
    date1 = dateTimeParser.parse("February 12, 2002 12:34:56.789");
    date2 = dateTimeParser.parse("November 18, 2001 1:23:11.321");
    defaultZone = TimeZone.getDefault();
    zone = TimeZone.getTimeZone("MET");
    TimeZone.setDefault(zone);
    dateTimeParser.setTimeZone(zone);
    date3 = dateTimeParser.parse("March 30, 2003 05:30:45.000");
    date4 = dateTimeParser.parse("March 30, 2003 01:10:00.000");
    date5 = dateTimeParser.parse("March 30, 2003 01:40:00.000");
    date6 = dateTimeParser.parse("March 30, 2003 02:10:00.000");
    date7 = dateTimeParser.parse("March 30, 2003 02:40:00.000");
    date8 = dateTimeParser.parse("October 26, 2003 05:30:45.000");
    dateTimeParser.setTimeZone(defaultZone);
    TimeZone.setDefault(defaultZone);
    calAmPm1 = Calendar.getInstance();
    calAmPm1.setTime(dateAmPm1);
    calAmPm2 = Calendar.getInstance();
    calAmPm2.setTime(dateAmPm2);
    calAmPm3 = Calendar.getInstance();
    calAmPm3.setTime(dateAmPm3);
    calAmPm4 = Calendar.getInstance();
    calAmPm4.setTime(dateAmPm4);
    cal1 = Calendar.getInstance();
    cal1.setTime(date1);
    cal2 = Calendar.getInstance();
    cal2.setTime(date2);
    TimeZone.setDefault(zone);
    cal3 = Calendar.getInstance();
    cal3.setTime(date3);
    cal4 = Calendar.getInstance();
    cal4.setTime(date4);
    cal5 = Calendar.getInstance();
    cal5.setTime(date5);
    cal6 = Calendar.getInstance();
    cal6.setTime(date6);
    cal7 = Calendar.getInstance();
    cal7.setTime(date7);
    cal8 = Calendar.getInstance();
    cal8.setTime(date8);
    TimeZone.setDefault(defaultZone);
}
 
源代码18 项目: rapidminer-studio   文件: CellTypeDateImpl.java
@Override
protected DateFormat initialValue() {
	return new SimpleDateFormat(CustomFilters.DATE_FORMAT_STRING, Locale.ENGLISH);
}
 
源代码19 项目: TencentKona-8   文件: MessageCatalog.java
private Locale getLocale(String localeName) {
    String language, country;
    int index;

    index = localeName.indexOf('_');
    if (index == -1) {
        //
        // Special case the builtin JDK languages
        //
        if (localeName.equals("de"))
            return Locale.GERMAN;
        if (localeName.equals("en"))
            return Locale.ENGLISH;
        if (localeName.equals("fr"))
            return Locale.FRENCH;
        if (localeName.equals("it"))
            return Locale.ITALIAN;
        if (localeName.equals("ja"))
            return Locale.JAPANESE;
        if (localeName.equals("ko"))
            return Locale.KOREAN;
        if (localeName.equals("zh"))
            return Locale.CHINESE;

        language = localeName;
        country = "";
    } else {
        if (localeName.equals("zh_CN"))
            return Locale.SIMPLIFIED_CHINESE;
        if (localeName.equals("zh_TW"))
            return Locale.TRADITIONAL_CHINESE;

        //
        // JDK also has constants for countries:  en_GB, en_US, en_CA,
        // fr_FR, fr_CA, de_DE, ja_JP, ko_KR.  We don't use those.
        //
        language = localeName.substring(0, index);
        country = localeName.substring(index + 1);
    }

    return new Locale(language, country);
}
 
源代码20 项目: DavidWebb   文件: WebbUtils.java
/**
 * Creates a new instance of a <code>DateFormat</code> for RFC1123 compliant dates.
 * <br>
 * Should be stored for later use but be aware that this DateFormat is not Thread-safe!
 * <br>
 * If you have to deal with dates in this format with JavaScript, it's easy, because the JavaScript
 * Date object has a constructor for strings formatted this way.
 * @return a new instance
 */
public static DateFormat getRfc1123DateFormat() {
    DateFormat format = new SimpleDateFormat(
            "EEE, dd MMM yyyy HH:mm:ss z", Locale.ENGLISH);
    format.setLenient(false);
    format.setTimeZone(TimeZone.getTimeZone("UTC"));
    return format;
}